Skip to content

Instantly share code, notes, and snippets.

@racecraftr
Created June 17, 2022 15:34
Show Gist options
  • Save racecraftr/d51988a7b1d7e24d90a6e93cb70a2d7a to your computer and use it in GitHub Desktop.
Save racecraftr/d51988a7b1d7e24d90a6e93cb70a2d7a to your computer and use it in GitHub Desktop.
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
private String getRandomLine(String path){
List<String> lines;
try{
lines = Files.readAllLines(Paths.get(path));
}
catch(IOException e) {
e.printStackTrace();
return "[ERROR]";
}
return lines.get((int)(Math.random() * lines.size()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment