Returns a password from standard input. @return password or empty string
()
| 98 | * @return password or empty string |
| 99 | */ |
| 100 | public static String password() { |
| 101 | // use standard input if no console is defined (such as in Eclipse) |
| 102 | if(NOCONSOLE) return input(); |
| 103 | // hide password |
| 104 | final char[] pw = System.console().readPassword(); |
| 105 | return pw != null ? new String(pw) : ""; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Prints a string to standard output, followed by a newline. |