O'Reilly logo

Java™ Phrasebook by Timothy Fisher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reading Text from Standard Input

BufferedReader inStream = new BufferedReader (
											new InputStreamReader(System.in)
											);
											String inLine = "";
											while ( !(inLine.equalsIgnoreCase("quit"))) {
											System.out.print("prompt> ");
											inLine = inStream.readLine();
											}

In a console program, it is common to read from the standard input, typically the command line. In this phrase, we show how you can read the standard input into a Java String variable.

Java contains three streams that are connected to the operating system streams. These are the standard input, standard output, and standard error streams. Respectively, they are defined in Java as the streams System.in, System.out, and System.err. We can make use of these streams to read or write to the operating systems ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required