Hello,
I am trying to display the contents in my text file into the console in sequence order, so it looks like an action replay from user inputs.
this is my text file:
Kardo
1
2
Kalio
1
1
Kardo
2
2
Kalio
2
1
Kardo
3
2
this is what i have so far:
System.out.print("Woud you like to replay the actions (y/n)? ");
String answer = input.getPrompt();
if (answer.equalsIgnoreCase("Y")) {
File file = new File("Actions.txt");
try {
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
System.out.println(line);
}
scanner.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
System.exit(0); // terminate the program
}
any help on how to do it would be great!
(I am a beginner)