001    /*
002     * Copyright (c) 2002-2007, Marc Prud'hommeaux. All rights reserved.
003     *
004     * This software is distributable under the BSD license. See the terms of the
005     * BSD license in the documentation provided with this software.
006     */
007    package jline.example;
008    
009    import jline.*;
010    
011    import java.io.*;
012    
013    public class PasswordReader {
014        public static void usage() {
015            System.out.println("Usage: java "
016                + PasswordReader.class.getName() + " [mask]");
017        }
018    
019        public static void main(String[] args) throws IOException {
020            ConsoleReader reader = new ConsoleReader();
021    
022            Character mask = (args.length == 0)
023                ? new Character((char) 0)
024                : new Character(args[0].charAt(0));
025    
026            String line = null;
027            do {
028                line = reader.readLine("enter password> ", mask);
029                System.out.println("Got password: " + line);
030            } while(line != null && line.length() > 0);
031        }
032    }