【发布时间】:2012-06-04 21:01:40
【问题描述】:
我知道 Git 和其他命令行界面能够隐藏用户的输入(对密码很有用)。有没有办法在Java中以编程方式做到这一点?我正在从用户那里获取密码输入,我希望他们的输入在该特定行上“隐藏”(但不是在所有行上)。这是我的代码(虽然我怀疑它会有所帮助......)
try (Scanner input = new Scanner(System.in)) {
//I'm guessing it'd probably be some property you set on the scanner or System.in right here...
System.out.print("Please input the password for " + name + ": ");
password = input.nextLine();
}
【问题讨论】:
标签: java command-line input user-input command-prompt