code: public static char[] readPassword(String msg) {
  		Console console = System.console();
  		if (console != null) {
  			return console.readPassword();
  		}
  		// console not available, most likely because of running inside IDE, try normal
  		scanner = getScanner();
  		System.out.print(msg);
  		return scanner.nextLine().toCharArray();
  	}
docs: Read password.
  
  @param msg the msg
  @return the char[]