java Occultare la password durante la digitazione
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java Occultare la password durante la digitazione相关的知识,希望对你有一定的参考价值。
import java.io.*;
public class HidePasswordFromCommandLine extends Thread {
boolean stopThread= false;
boolean hideInput= false;
boolean shortMomentGone= false;
public void run() {
try {
sleep(500);
} catch (InterruptedException e) {}
shortMomentGone= true;
while (!stopThread) {
if (hideInput) {
System.out.print("\b*");
}
try {
sleep(1);
} catch (InterruptedException e) {}
}
}
public static void main(String[] arguments) {
String name= "";
String password= "";
HidePasswordFromCommandLine hideThread= new HidePasswordFromCommandLine();
hideThread.start();
BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
try {
System.out.println("Name: ");
// Aspetta l'immissione dello username e pulisce il buffer della tastiera
do {
name= in.readLine();
}
while (hideThread.shortMomentGone == false);
//
// Nasconde il thread e sovrascrive l'input con "*"
hideThread.hideInput= true;
// Legge la password
System.out.println("\nPassword:");
System.out.print(" ");
password = in.readLine();
hideThread.stopThread= true;
}
catch (Exception e) {}
System.out.print("\b \b");
// Solo per testing, eliminare!
System.out.println("\n\nLogin= " + name);
System.out.println("Password= " + password);
}
}
以上是关于java Occultare la password durante la digitazione的主要内容,如果未能解决你的问题,请参考以下文章
HDU5976 LA7728 Detachment逆元+前缀和+二分
java [Actividad Dinamica] Crear una actividad dinamica en Android enviando la clase por String #Andr
MySQL8.0提示 caching_sha2_passwor‘ cannot be loaded
HDU1416 POJ1078 UVA653 LA5507 GizilchDFS
HDU5972 LA7724 Regular Number位运算+字符串匹配
解决mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor