Finally you can easily accept password from console in Java, without echoing them.最后,您可以很容易地接受密码,从控制台在Java中,没有附和他们。

This long unmet need has been addressed in这一长期未得到满足的需求已得到解决在 JDK 1.6的JDK 1.6 codeline. codeline 。

A new class -新一类- java.io.Console java.io.console has been defined to handle console I/O.已确定了处理控制台的I / O 。

To accept password from console in接受密码,从控制台在 JDK 6.0 (aka JDK 1.6)的JDK 6.0 (又名的JDK 1.6 ) use either:使用:
public char[] readPassword() 市民焦[ ] readpassword ( )
or
public char[] readPassword(String fmt, Object… args) 市民焦[ ] readpassword (字符串裂变材料条约,对象… args )

 Sample code:   Console cons;   char[] passwd;   if ((cons = System.console()) != null &&        (passwd = cons.readPassword(”[%s]“, “Password:”)) != null) {        // Use the passwd for authentication etc.        ….; // Your code        // After you are done zero the character array in memory for reducing security risk java.util.Arrays.fill(passwd, ‘ ‘); }示例代码:控制台的意见;烧焦[ ]密码;如果( (考虑= system.console ( ) ) ! =空& & (密码= cons.readpassword ( “ [ % ] ” , “密码: ” ) ) ! =空) ( / /使用密码进行身份验证等… … 。 ; / /您的代码/ /后,你是做了零的性质数组在内存中为减少安全风险java.util.arrays.fill (密码, ' ' ) ; 

So could I entice you yet to所以我想引诱你仍未 download JDK 1.6下载的JDK 1.6 ?