01: /*
02: * Copyright (c) 2002-2007, Marc Prud'hommeaux. All rights reserved.
03: *
04: * This software is distributable under the BSD license. See the terms of the
05: * BSD license in the documentation provided with this software.
06: */
07: package jline.example;
08:
09: import jline.*;
10:
11: import java.io.*;
12:
13: public class PasswordReader {
14: public static void usage() {
15: System.out.println("Usage: java "
16: + PasswordReader.class.getName() + " [mask]");
17: }
18:
19: public static void main(String[] args) throws IOException {
20: ConsoleReader reader = new ConsoleReader();
21:
22: Character mask = (args.length == 0) ? new Character((char) 0)
23: : new Character(args[0].charAt(0));
24:
25: String line = null;
26: do {
27: line = reader.readLine("enter password> ", mask);
28: System.out.println("Got password: " + line);
29: } while (line != null && line.length() > 0);
30: }
31: }
|