Read standard input (stdin) with in Java

In JDK 1.6, reading standard input (stdin) changed to a simple approach using

readLine takes input from which is a handle to which uses the InputStream class.

System.out.println("Enter text:");
// Note: console.readLine returns null when used from an IDE
String input = System.console().readLine();

Using Scanner is a friendly approach when using an IDE.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>