Here you can find the source of readPassword(String format, Object... args)
private static char[] readPassword(String format, Object... args)
//package com.java2s; /*//from w w w . j a v a2s .c o m Copyright 2016 Seth Traverse This file is part of SecureFiles. SecureFiles is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SecureFiles is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SecureFiles. If not, see <http://www.gnu.org/licenses/>. */ import java.util.Scanner; public class Main { private static char[] readPassword(String format, Object... args) { if (System.console() != null) return System.console().readPassword(format, args); System.out.println("WARNING -> Console password input unsupported, password entry in insecure mode!"); return readLine(format, args).toCharArray(); } private static String readLine(String format, Object... args) { System.out.print(String.format(format, args)); return new Scanner(System.in).nextLine(); } }