Reading data from keyboard
There are many ways to read data from the keyboard. For example:
InputStreamReader
Console
Scanner
DataInputStream etc.
InputStreamReader class
InputStreamReader class can be used to read data from keyboard.It performs two tasks:
connects to input stream of keyboard
converts the byte-oriented stream into character-oriented stream
BufferedReader class
BufferedReader class can be used to read data line by line by readLine() method.
Java Console Class
The Java Console class is be used to get input from console. It provides methods to read texts
and passwords.
If you read password using Console class, it will not be displayed to the user.
The java.io.Console class is attached with system console internally. The Console class is
introduced since 1.5.
String text=System.console().readLine();
System.out.println("Text is: "+text);