1 17 18 package org.apache.geronimo.deployment.cli; 19 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 import java.io.Writer ; 23 import java.io.OutputStream ; 24 import java.io.PrintWriter ; 25 import java.io.OutputStreamWriter ; 26 27 import jline.ConsoleReader; 28 29 37 public class InputPrompt 38 { 39 private ConsoleReader reader; 40 41 public InputPrompt(final InputStream in, final Writer out) throws IOException { 42 this.reader = new ConsoleReader(in, out); 43 } 44 45 public InputPrompt(final InputStream in, final OutputStream out) throws IOException { 46 this(in, new PrintWriter (new OutputStreamWriter (out), true)); 47 } 48 49 52 public String getInput(final String prompt, final Character mask) throws IOException { 53 if (mask == null) { 54 return reader.readLine(prompt); 55 } 56 else { 57 return reader.readLine(prompt, mask); 58 } 59 } 60 61 public String getInput(final String prompt, final char mask) throws IOException { 62 return getInput(prompt, new Character (mask)); 63 } 64 65 public String getInput(final String prompt) throws IOException { 66 return getInput(prompt, null); 67 } 68 69 72 public String getPassword(final String prompt) throws IOException { 73 return getInput(prompt, '*'); 74 } 75 } | Popular Tags |