KeyEvent.VK_ + int i,输出Bot可能吗?

时间:2015-11-14 10:16:19

标签: java bufferedreader keyevent

从昨天起,我正在开发一个程序,永久保存1个密码,所以它只能用于一次。保存的密码将在以后通过键盘输出打印,这就是为什么我认为,id以数组开头。许多人在其他问题中告诉我,他们会使用ObjectArray或类似的东西。我对Java很新,这就是为什么我会感谢帮助。顺便说一句,如果你提出一些建议,如果它有点深入,我会欣赏它。 这是守则。

Robot bot = new Robot();
BufferedReader dmc = new BufferedReader(new InputStreamReader(System.in));

System.out.println("How many digits has your Password?");
String digit = dmc.readLine();
int d = Integer.parseInt(digit);
String[] password = new String[d];
System.out.println("Please enter your Password in single letters.");

int i = 0;
while (password[d - 1] == null) {
    password[i] = dmc.readLine();
    i++;
}

int j = 0;
while(j != d){
    password[j] = "KeyEvent.VK_" + password[j];
    j++;
}

很差,这不能正常工作。

1 个答案:

答案 0 :(得分:0)

出于安全原因,您应该避免在字符串中存储密码。您可以阅读更多here

BufferedReader dmc = new BufferedReader(new InputStreamReader(System.in));

System.out.println("How many digits has your Password?");
String digit = dmc.readLine();
int d = Integer.parseInt(digit);
char[] password = new char[d];
System.out.println("Please enter your Password in single letters.");

dmc.read(password);

Stream.of(password).forEach(System.out::println);