Created
June 17, 2022 15:34
-
-
Save racecraftr/d51988a7b1d7e24d90a6e93cb70a2d7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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