IOUtils { public static void copy(InputStream input, OutputStream output) throws IOException { int n; final byte[] buffer = new byte[BUFFER_SIZE]; while (EOF != (n = input.read(buffer))) { output.write(buffer, 0, n); } } private  IOUtils(); static void copy(InputStream input, OutputStream output); static void write(String str, OutputStream out); static String toString(InputStream input); static void closeQuietly(InputStream is); static void consumeAndClose(InputStream is); static InputStream getResourceAsStream(String name); static String getResourceAsString(String name); static byte[] readToBytes(InputStream inputStream); static File getFile(String classPathLocation);  }
@Test public void testCopy() throws IOException { final byte[] array = new byte[] { 1, 2, 3 }; final ByteArrayInputStream bios = new ByteArrayInputStream(array); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(bios, baos); Assert.assertArrayEquals(array, baos.toByteArray()); }