@Test public void testReadingFromStreamToByteArray() throws Exception { byte[] expected = "content".getBytes(); ByteArrayInputStream input = new ByteArrayInputStream(expected); byte[] actual = IO.readIntoByteArray(input); assertEquals(new String(expected), new String(actual)); }
public static byte[] readIntoByteArray(InputStream in) throws IOException { ByteArrayOutputStream content = new ByteArrayOutputStream(); pipe(in, content); return content.toByteArray(); }
IO { public static byte[] readIntoByteArray(InputStream in) throws IOException { ByteArrayOutputStream content = new ByteArrayOutputStream(); pipe(in, content); return content.toByteArray(); } }
IO { public static byte[] readIntoByteArray(InputStream in) throws IOException { ByteArrayOutputStream content = new ByteArrayOutputStream(); pipe(in, content); return content.toByteArray(); }  }
IO { public static byte[] readIntoByteArray(InputStream in) throws IOException { ByteArrayOutputStream content = new ByteArrayOutputStream(); pipe(in, content); return content.toByteArray(); }  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 byte[] readIntoByteArray(InputStream in) throws IOException { ByteArrayOutputStream content = new ByteArrayOutputStream(); pipe(in, content); return content.toByteArray(); }  static byte[] readIntoByteArray(InputStream in); static void pipe(InputStream source, OutputStream destination); static void pipe(Reader source, Writer destination); static String readIntoString(Reader reader);  }