📜  从 xz 文件中获取随机单词 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:18.334000             🧑  作者: Mango

代码示例1
private static List 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()));
}