[url]http://java.sun.com/docs/books/tutorial/essential/io/cl.html[/url]
The Java platform supports this kind of interaction in two ways: through the Standard Streams and through the Console.
java平台支持2种控制台交互方式。1是通过标准的stream 另外一种就是 console
[b]Standard Streams[/b]
[b]The Console[/b]
[url]http://java.sun.com/javase/6/docs/api/java/io/Console.html[/url]
Console流相对标准流来说是一个更高级的选项。Console类有大部分标准流提供的功能。另外它特别适合用户名密码这样的情况
why?
This method helps secure password entry in two ways. First, it suppresses echoing, so the password is [b]not visible[/b] on the user's screen. Second, readPassword returns a[b] character array[/b], not a String, so the password can be overwritten, removing it from memory as soon as it is no longer needed.
这个对象有可能返回一个null。原因是 not permitted / OS doesn't support them / or because the program was launched in a noninteractive environment.
The Java platform supports this kind of interaction in two ways: through the Standard Streams and through the Console.
java平台支持2种控制台交互方式。1是通过标准的stream 另外一种就是 console
[b]Standard Streams[/b]
InputStreamReader cin = new InputStreamReader(System.in);
[b]The Console[/b]
[url]http://java.sun.com/javase/6/docs/api/java/io/Console.html[/url]
Console流相对标准流来说是一个更高级的选项。Console类有大部分标准流提供的功能。另外它特别适合用户名密码这样的情况
why?
This method helps secure password entry in two ways. First, it suppresses echoing, so the password is [b]not visible[/b] on the user's screen. Second, readPassword returns a[b] character array[/b], not a String, so the password can be overwritten, removing it from memory as soon as it is no longer needed.
char [] oldPassword = c.readPassword("Enter your old password: ");
System.console()
这个对象有可能返回一个null。原因是 not permitted / OS doesn't support them / or because the program was launched in a noninteractive environment.