1 package com.beust.jcommander.internal; 2 3 import com.beust.jcommander.ParameterException; 4 5 import java.io.BufferedReader; 6 import java.io.IOException; 7 import java.io.InputStreamReader; 8 9 public class DefaultConsole implements Console { 10 print(String msg)11 public void print(String msg) { 12 System.out.print(msg); 13 } 14 println(String msg)15 public void println(String msg) { 16 System.out.println(msg); 17 } 18 readPassword(boolean echoInput)19 public char[] readPassword(boolean echoInput) { 20 try { 21 // Do not close the readers since System.in should not be closed 22 InputStreamReader isr = new InputStreamReader(System.in); 23 BufferedReader in = new BufferedReader(isr); 24 String result = in.readLine(); 25 return result.toCharArray(); 26 } 27 catch (IOException e) { 28 throw new ParameterException(e); 29 } 30 } 31 32 } 33