### Question:
IO { public static void pipe(InputStream source, OutputStream destination) throws IOException { int r = -1; byte[] buffer = new byte[8096]; while ((r = source.read(buffer, 0, buffer.length)) != -1) { destination.write(buffer, 0, r); } }  static byte[] readIntoByteArray(InputStream in); static void pipe(InputStream source, OutputStream destination); static void pipe(Reader source, Writer destination); static String readIntoString(Reader reader);  }### Answer:
@Test public void testPipingStreams() throws Exception { String expected = "abc"; InputStream source = new ByteArrayInputStream(expected.getBytes()); OutputStream destination = new ByteArrayOutputStream(); IO.pipe(source, destination); assertEquals(expected, destination.toString()); }
@Test public void testPipingReadersAndWriters() throws Exception { String expected = "abc"; Reader source = new StringReader(expected); Writer destination = new StringWriter(); IO.pipe(source, destination); assertEquals(expected, destination.toString()); }