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 ?