Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

get random word from xz file

private static List<String> lines = null;
static {
    try {
        lines = Files.readAllLines(new File("bundles.txt").toPath());
    } catch (IOException e) {
        e.printStackTrace();
    }
}
private Random rand = new Random();

public String getRandomItem() {
    return lines.get(rand.nextInt(lines.size()));
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #random #word #xz #file
ADD COMMENT
Topic
Name
5+9 =