package JavaLinkedListDemo; import java.io.* ; // required to use the BufferedReader class public class jmhUtilities { /** Default constructor to create a new instance of jmhUtilities. * This constructor is not called because the jmhUtilities class * contains only static methods. */ jmhUtilities() { } /** Get a line of text entered by the user from the console. The need for all * this code is one thing that many people don’t like about Java! 8-( *

Here's how this method works:

* *

As noted above, this complexity is definitely a turn-off to many * people, but it is a nice demonstration of OOP and “building bridges” * between objects, a common requirement of all OO languages and * systems.

* @return String entered by the user */ public static String ReadLine() { String strUserEntry = "" ; // string entered by the user InputStreamReader isrConsole = new InputStreamReader( System.in ) ; BufferedReader brConsole = new BufferedReader( isrConsole ) ; try { System.out.flush() ; // ensure that prompt is visible strUserEntry = brConsole.readLine() ; // read the user's input } catch ( IOException ioe ) { System.err.println( "An IOException has occurred in method ReadLine." ) ; System.err.println( "The system reported:" ) ; System.err.println( ioe.toString() ) ; // the toString() method is not really needed above, but I have // included it for clarity to show what the system actually does // automatically System.exit( 1 ) ; // terminate program execution with an error flag } return strUserEntry ; } }