Skip to content

Instantly share code, notes, and snippets.

@ldub
Last active August 29, 2015 14:16
Show Gist options
  • Save ldub/1d1445841dc3e92ecacc to your computer and use it in GitHub Desktop.
Save ldub/1d1445841dc3e92ecacc to your computer and use it in GitHub Desktop.
ShuffleOneLine
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Shuffle {
public static void main(String[] args) {
String str = "shuf_ftw";
try {
String shuffled = (new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(new String[] { "sh", "-c", "echo " + str + " | fold -w1 | shuf | tr -d '\n'" }).getInputStream()))).readLine();
System.out.println(shuffled);
} catch (Exception e) {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment