/** * Creates a Console that reads from and writes to the provided streams. * * @param in the console's input stream * @param out the console's output stream */ public Console(InputStream in, OutputStream out) { this.in = in; this.cursorBuffer = new StringBuffer(); this.ansiEnabled = true; this.forceAnsi = false; try { this.ansiSupported = checkAnsiSupported(out, checkOS()); } catch (UnsatisfiedLinkError e) { this.ansiSupported = false; } catch (Throwable e) { this.ansiSupported = false; } if (out instanceof PrintStream) { this.out = (PrintStream) out; } else { boolean autoFlush = true; this.out = new PrintStream(out, autoFlush); } }
/** * Creates a Console that reads from and writes to the provided streams. * * @param in the console's input stream * @param out the console's output stream */ public Console(InputStream in, OutputStream out) { this.in = in; this.cursorBuffer = new StringBuffer(); this.ansiEnabled = true; this.forceAnsi = false; try { this.ansiSupported = checkAnsiSupported(out, checkOS()); } catch (UnsatisfiedLinkError e) { this.ansiSupported = false; } catch (Throwable e) { this.ansiSupported = false; } if (out instanceof PrintStream) { this.out = (PrintStream) out; } else { boolean autoFlush = true; this.out = new PrintStream(out, autoFlush); } }
/** * Creates a Console that reads from and writes to the provided streams. * * @param in the console's input stream * @param out the console's output stream */ public Console(InputStream in, OutputStream out) { this.in = in; this.cursorBuffer = new StringBuffer(); this.ansiEnabled = true; this.forceAnsi = false; try { this.ansiSupported = checkAnsiSupported(out, checkOS()); } catch (UnsatisfiedLinkError e) { this.ansiSupported = false; } catch (Throwable e) { this.ansiSupported = false; } if (out instanceof PrintStream) { this.out = (PrintStream) out; } else { boolean autoFlush = true; this.out = new PrintStream(out, autoFlush); } }
@Test public void testWindows10Detection() { Console console = new Console(); boolean returned = false; try { returned = console.checkAnsiSupported(System.out, "windows 10"); } catch (Throwable er) { returned = true; } assertTrue(returned); }
@Test public void testWindows7Detection() throws Throwable { Console console = new Console(); assertFalse(console.checkAnsiSupported(System.out, "windows 7")); } }