Added fallback for IDE case

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
Jim Martens 2017-04-25 16:53:37 +02:00
parent 0a2846d7f2
commit 3434fcae70
1 changed files with 12 additions and 2 deletions

View File

@ -49,9 +49,19 @@ class FormUtil {
* @return the entered password
*/
static String readPassword() {
String password;
String password = "";
System.out.print("Password: ");
password = String.valueOf(System.console().readPassword());
if (System.console() != null) {
password = String.valueOf(System.console().readPassword());
} else {
try {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
password = stdin.readLine();
} catch (IOException e) {
e.printStackTrace();
}
}
return password;
}