@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()); }
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); } }
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); } } }
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); } }  }
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); }
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);  }