/** * Create a console reader. * * @param systemIn The input stream * @return The console reader * @throws IOException if there is an error */ protected ConsoleReader createConsoleReader(InputStream systemIn) throws IOException { // need to swap out the output to avoid logging during init final PrintStream nullOutput = new PrintStream(new ByteArrayOutputStream()); final PrintStream originalOut = Log.getOutput(); try { Log.setOutput(nullOutput); ConsoleReader consoleReader = new ConsoleReader(systemIn, out); consoleReader.setExpandEvents(false); return consoleReader; } finally { Log.setOutput(originalOut); } }
protected ConsoleReader createConsoleReader(InputStream systemIn) throws IOException { // need to swap out the output to avoid logging during init final PrintStream nullOutput = new PrintStream(new ByteArrayOutputStream()); final PrintStream originalOut = Log.getOutput(); try { Log.setOutput(nullOutput); ConsoleReader consoleReader = new ConsoleReader(systemIn, out); consoleReader.setExpandEvents(false); return consoleReader; } finally { Log.setOutput(originalOut); } }
/** * Constructs a <tt>Console</tt> with <tt>System.in</tt> and <tt>System.out</tt> as the I/O streams. */ public Console(InstallData installData, ConsolePrefs prefs) { this.installData = installData; Log.setOutput(new PrintStream(new OutputStream() { @Override public void write(int b) throws IOException { } })); if (prefs.enableConsoleReader) { initConsoleReader(); } if (consoleReader == null) { console = System.console(); } }