📄 inputmasking.java
字号:
//InputMasking.java
import java.io.*;
public class InputMasking {
String getPassword(String initial) throws IOException {
MaskingThread listeningthread = new MaskingThread(initial);
Thread thread_instance = new Thread(listeningthread);
String password = "";
thread_instance.start();
while (true) {
char input = (char) System.in.read();
listeningthread.stopMasking();
if (input == '\r') {
input = (char) System.in.read();
if (input == '\n')
break;
else
continue;
} else if (input == '\n')
break;
else
password += input;
}
return password;
}
private String input = null;
public String consoleInput(){
BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));
try {
input = sin.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return input;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -