I'm having trouble with a method I've made. It reads off from a text file, and prints the contents onto the console with a delay, however, while it's printing it can randomly take inputs from the user. Sometimes it intertwines with the contents it's printing. Is there a better way to do this?
public static void filePrint(String location) throws IOException, FileNotFoundException, InterruptedException {
File flScannedFile = new File(location);
Scanner scFileScanner = new Scanner(flScannedFile);
while (scFileScanner.hasNext()) {
String file = scFileScanner.nextLine();
System.out.print(file);
Thread.sleep(650);
}
}
System.out.print(file);toSystem.out.println(file);It's looks better in printing.