I am looking for a way to stop the progress of the following bar:
private static void cancellaaaaaaaaable() throws InterruptedException {
System.out.println("Cancellaaaaaaable!");
System.out.print(ANSI_RED);
for(int i = 0; i < 79; i++){
// Something that allows user input/interaction capable to stop the progressbar
System.out.print("█");
TimeUnit.MILLISECONDS.sleep(500);
}
System.out.print(ANSI_RESET);
}
When the progressbar starts, the user should have about 40 seconds to decide to stop and cancel the progress bar.
Is there a way to do that? It's great any keyboard input, except those that brutally stop the process.