### Question:
IO { public void set() { System.setIn(stdin); System.setOut(stdout); System.setErr(stderr); } IO(); void set();  }### Answer:
@Test void stashIo() throws UnsupportedEncodingException { final IO testIO = new IO(); final ByteArrayOutputStream stdout = new ByteArrayOutputStream(); final PrintStream stdoutPs = new PrintStream(stdout); final ByteArrayOutputStream stderr = new ByteArrayOutputStream(); final PrintStream stderrPs = new PrintStream(stderr); final IO overridenIO = new IO(new InputStream() { @Override public int read() { return -1; } }, stdoutPs, stderrPs); overridenIO.set(); try { System.out.println("test out stash"); stdoutPs.flush(); System.err.println("test err stash"); stderrPs.flush(); assertEquals("test out stash\n", stdout.toString("UTF-8")); assertEquals("test err stash\n", stderr.toString("UTF-8")); } finally { testIO.set(); } }