在控制台上隐藏密码输入 Window
Hide Password Input On Console Window
当我在控制台输入我的密码时 window 它是可见的,无论如何可以更改它以使其不可见吗?这是我的代码:
String user, pass, host;
Scanner sc = new Scanner(System.in);
System.out.println("Type userid, password, hostname or ipaddress: ");
user = sc.next();
pass = sc.next();
host = sc.next();
System.out.println(user + " " + pass + " " + host);
Methods md = new Methods();
md.createTable(user, pass, host);
使用ConsolereadPassword()
方法:
char[] passwd = System.console().readPassword("[%s]", "Password:");
当我在控制台输入我的密码时 window 它是可见的,无论如何可以更改它以使其不可见吗?这是我的代码:
String user, pass, host;
Scanner sc = new Scanner(System.in);
System.out.println("Type userid, password, hostname or ipaddress: ");
user = sc.next();
pass = sc.next();
host = sc.next();
System.out.println(user + " " + pass + " " + host);
Methods md = new Methods();
md.createTable(user, pass, host);
使用ConsolereadPassword()
方法:
char[] passwd = System.console().readPassword("[%s]", "Password:");