BufferedReader
The most basic method to get data from the System.in input stream
BufferedReader br = new BufferedReader (new InputStreamReader (system.in)); try { System.out.println (Br.readline ()) ;} catch (IOException e) { e.printstacktrace ();}
Scanner
Scanner sc = new Scanner (system.in); System.out.println (Sc.nextline ());
Console
Java6 New
Console console = System.Console (), if (console! = null) { System.out.println (Console.ReadLine ());}
Description
Console is primarily designed to facilitate the interaction of the program with the user, but there is a limitation of the need to use the system comes with the console to run the program, if used in the IDE, there is a great possibility to get the console.
Another feature of the console is the ability to hide passwords:
Console console = System.Console (), if (console! = null) { System.out.println (Console.readpassword ());}
This will not see the password entered by the user, but there is no way to display the user's input as "*" or other characters
Scanner convenient to convert the user's input to the corresponding Java type, in addition, scanner input source is not limited to system.in, but also can be other input source.
"Java" console input section