Code example for PrintStream

Methods: flush, print

0
 
    /** 
     * Reads the password from stdin and returns it as a string. 
     * 
     * @param keyFile The file containing the private key.  Used to prompt the user. 
     */ 
    private static String readPassword(File keyFile) {
        // TODO: use Console.readPassword() when it's available. 
        System.out.print("Enter password for " + keyFile + " (password will not be hidden): ");
        System.out.flush();
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        try { 
            return stdin.readLine();
        } catch (IOException ex) {
            return null; 
        } 
    } 
 
    /** 
     * Decrypt an encrypted PKCS 8 format private key. 
     *