@Test public void testRoundTrip() throws Exception { byte[] bytes = { 1, 2, 3, -127, 100, 127}; InputStream is = new ByteArrayInputStream(bytes); byte[] bytes2 = IoUtils.toByteArray(is); assertNotSame(bytes2, bytes); assertEquals(bytes.length, bytes2.length); for (int i = 0; i < bytes.length; ++i) { assertEquals(bytes[i], bytes2[i]); } }
public static byte[] toByteArray(InputStream in) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); copy(in, out); return out.toByteArray(); }
IoUtils { public static byte[] toByteArray(InputStream in) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); copy(in, out); return out.toByteArray(); } }
IoUtils { public static byte[] toByteArray(InputStream in) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); copy(in, out); return out.toByteArray(); }  }
IoUtils { public static byte[] toByteArray(InputStream in) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); copy(in, out); return out.toByteArray(); }  static byte[] toByteArray(InputStream in); static long copy(InputStream from, OutputStream to); }
IoUtils { public static byte[] toByteArray(InputStream in) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); copy(in, out); return out.toByteArray(); }  static byte[] toByteArray(InputStream in); static long copy(InputStream from, OutputStream to);  }