Wednesday, February 11, 2015

Java: manually holding execution

This snippet comes in handy when you want to hang execution of the command line app until user presses ENTER on the keyboard:

BufferedReader reader = new BufferedReader(new InputStreamReader(;
System.out.print("Waiting for you to press ENTER:");
reader.readLine(); // waiting for user indefinitely until ENTER is pressed