 <p>Using the <strong>BufferReader/InputReader(System.in)</strong> classes is a good alternative to using the Scanner class in the sense that code operation is not blocked while waiting for input from the User. This is why the <strong>while</strong> loop is in play so as to actually wait for User Input. While waiting for User input, several things such as running other code can take place including the start of other Threads etc.</p> <p>On the other hand, when using a <strong>Scanner</strong> object, to get input from the User you might have:</p> <pre><code>Scanner scan = new Scanner(System.in); String name = scan.nextLine(); </code></pre> <p>When the <strong>scan.nextLine();</strong> method is encountered code is completely blocked until a User enters something into the Console unless special Thread &amp; thread locks have been put into play within your code. As a simple example, try yourself to set up a console User Input request which only gives the User 10 or 20 seconds to provide that input and upon timeout the application closes (perhaps for a login or whatever).</p> <p>This is difficult to do using the <strong>Scanner</strong> object (but not impossible) since when the input request is issued further code operation is blocked yet with <strong>BufferReader/InputReader</strong> this is relatively simple to carry out since code blocking is done with your own code (usually with a <strong>while</strong> Loop). Below is a simple method example which allows you to ask the User to provide input but with a time limit:</p> <pre><code>/** * Method for asking a question (prompt) requiring an input from User within a Console window. Question (prompt) * contains a supplied time limit to answer unless 0 is supplied in which case then there is no time limit.&lt;br&gt;&lt;br&gt; * * Whether this method is used within a GUI application or a Console application, code is halted until the ask() method * has either timed out or User input has been provided. The ask() method does not allow for an Empty Answer (if just * the ENTER key is pressed). Instead it continues to poll for an answer until either one is given or the time limit expires.&lt;br&gt;&lt;br&gt; * * &lt;b&gt;Example Usage:&lt;/b&gt;&lt;pre&gt; * * System.out.println("[10 Seconds]"); * String question = "What is 1+1?\nA: 1\tB: 2\tC: 3\tD: 4\n"; * String answer = ask(question, 10); * * if (answer.equalsIgnoreCase("b")) { System.out.println("CORRECT!"); } * else { System.out.println("WRONG!"); }&lt;/pre&gt;&lt;br&gt; * * @param question (String) The prompt (question) to display within console.&lt;br&gt; * * @param timeLimit (Integer) The time limit in seconds for each question (prompt) to be answered. If 0 is supplied * then there is no time limit.&lt;br&gt; * * @param options (Optional - String)&lt;pre&gt; * * tickDisplay - (Default is an asterisk (*)) By default an asterisk is is displayed in sequence for * every second that expires unless of course the time limit supplied is 0 in which case * no tick display is shown. If a null string is supplied for this optional parameter then * again no tick display is shown. Any string can be supplied here. * * timeOutMessage - This optional parameter allows you to change the default display message that is displayed * when the supplied time limit has expired. This message is not displayed if a time limit of * 0 is supplied or a Null String ("") is supplied in this parameter. The default mesage is: * "\b\b\b\u001B[31mYour time is up for this question!\u001B[39;49m".&lt;/pre&gt; * @return (String) */ public static String ask(final String question, final int timeLimit, final String... options) { boolean questionAnswered = false; String tickDisplay = "*"; String timeOutMessage = "\b\b\b\u001B[31mYour time is up for this question!\u001B[39;49m"; if (options.length &gt; 0) { if (options.length &gt;= 1) { tickDisplay = options[0]; } if (options.length == 2) { timeOutMessage = options[1]; } } final String td = tickDisplay; final String tom = timeOutMessage; // Establish a new Thread for performing our question timing... Thread timerThread = new Thread(new Runnable() { @Override public void run() { String tickDisplayrun = td; String timeOutMessageRun = tom; try { // See if this thread has been interrupted. If it has then // we stop our timer While/Loop (a gracefull Thread Stop). while (!Thread.currentThread().isInterrupted()) { for (int seconds = timeLimit; seconds &gt;= 1; seconds--){ // Break out of this timer FOR loop if the question // was answered by using Thread.interrupt(). if (questionAnswered) { Thread.currentThread().interrupt(); break;} // Show that timer is ticking away... if (!td.equals("")) { tickDisplayrun = tickDisplayrun.replace("&lt;tl&gt;", String.valueOf(timeLimit)).replace("&lt;s&gt;", String.valueOf(seconds)); System.out.print(tickDisplayrun); } // ========================================================== // Or you can use this... // if (seconds &lt; secondsForTimout) { System.out.print("-"); } // System.out.print(seconds); // ========================================================== Thread.sleep(1000); } // If the question wasn't answered and our timer loop has // expired then inform User that time is up. if (!questionAnswered) { if (!timeOutMessageRun.equals("")) { timeOutMessageRun = timeOutMessageRun.replace("&lt;tl&gt;", String.valueOf(timeLimit)); System.out.print(timeOutMessageRun); } Thread.currentThread().interrupt(); } } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }); // Catch Exceptions for BufferReader()/InputStreamReader()... try { // Declare a BufferReader object so as to get input from User. // We use BufferReader along with InputStreamReader(System.in) // for this. BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println(question); // Declare User input variable &amp; initialize to a Null String String input = ""; // Make sure our timer thread is dead before restarting it. //while (timerThread.isAlive()){} // Start the Timer Thread if (timeLimit &gt; 0) { timerThread.start(); } // Loop through input from the User do { // Wait until we have User input data to complete a readLine() // or until our timer thread has set the timeOut variable to // true. while (!br.ready()) { // If our timer thread has timed Out then // let's get outta this question altogether. // First we get out of our 'wait for input' loop... if (timeLimit &gt; 0 &amp;&amp; !timerThread.isAlive()) { break; } } // Then we get out of our Do/While Loop. if (timeLimit &gt; 0 &amp;&amp; !timerThread.isAlive()) { break; } // No time-out so let's move on... // Let's see what the User supplied for an answer. // If just ENTER was supplied then input will contain // a Null String and the User can still enter an answer // until the question is timed out. input = br.readLine(); // remove any unwanted text from System.out.print() // that had made its way through the timer thread. System.out.print("\b\b\b\b\b"); } while ("".equals(input)); // Stop the timer thread. timerThread.interrupt(); return input; } catch (IOException ex) { return ex.getMessage(); } } </code></pre> <p>An example of how you can use this method:</p> <pre><code>String strg = ask("What is your name? (you have 20 seconds to answer)", 20, ""); if (strg.equals("")) { System.out.println("\nNo name provided...Quitting!"); System.exit(0); } System.out.println("\nYour name is: " + strg); </code></pre> <p>Just for the fun of it, try to accomplish the same task using the <strong>Scanner</strong> class.</p> <p>As for the code block example you posted, it looks as though it simply asks the User to enter a continuous series of strings. The <strong>while</strong> loop within the code continues to accept input from the User (once the ENTER key is hit) until he/she enters null (which they can't, CTRL+D or CTRL+Z doesn't always work). At this point polling for input is halted (the <strong>while</strong> loop ends) and the input which had been placed into a String List Array is iterated through and displayed within the console window. What you want to do with the strings contained within the List array is entirely up to you....save it to a file, display it within a JTextArea component, whatever. </p> <p>Now...there is a bit of a flaw with the code and the problem lies within the <strong>while</strong> loop condition. While the User is providing input he/she is permitted to continuously enter strings until the cows come home but there is no way to satisfy the the condition within the <strong>while</strong> loop. The is no bulletproof way to provide 'null' to the console so that the rest of our code can be run which iterates through the <strong>List&lt;></strong> array and displays each element which consists of strings the User previously entered. The solution to this is to supply an additional condition which permits the User to enter the word <strong>quit</strong> so as to indicate "I'm done making my entries...do your thing". So we change the <strong>while</strong> Loop to start like this:</p> <pre><code>while ((line = br.readLine()) != null &amp;&amp; !line.equalsIgnoreCase("quit")) { ....... ....... } </code></pre> <p>Now, if the User enters the single word <strong>quit</strong> (regardless of letter case) we exit our <strong>while</strong> loop and the remaining code is run. We don't want to use a Null String (<strong>""</strong>) for this because we might want the blank lines provided by the User during the text entry which is usually done when starting a new paragraph for example.</p>