@Test public void copiesStream() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); copy(new ByteArrayInputStream(mBytes), outputStream); assertArrayEquals(mBytes, outputStream.toByteArray()); }
public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException { byte buffer[] = new byte[BUFFER_SIZE]; int bytesRead = -1, totalBytesRead = 0; while ((bytesRead = inputStream.read(buffer)) >= 0) { totalBytesRead += bytesRead; outputStream.write(buffer, 0, bytesRead); } }
Streams { public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException { byte buffer[] = new byte[BUFFER_SIZE]; int bytesRead = -1, totalBytesRead = 0; while ((bytesRead = inputStream.read(buffer)) >= 0) { totalBytesRead += bytesRead; outputStream.write(buffer, 0, bytesRead); } } }
Streams { public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException { byte buffer[] = new byte[BUFFER_SIZE]; int bytesRead = -1, totalBytesRead = 0; while ((bytesRead = inputStream.read(buffer)) >= 0) { totalBytesRead += bytesRead; outputStream.write(buffer, 0, bytesRead); } } private  Streams(); }
Streams { public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException { byte buffer[] = new byte[BUFFER_SIZE]; int bytesRead = -1, totalBytesRead = 0; while ((bytesRead = inputStream.read(buffer)) >= 0) { totalBytesRead += bytesRead; outputStream.write(buffer, 0, bytesRead); } } private  Streams(); static void copy(InputStream inputStream, OutputStream outputStream); static ByteArrayOutputStream read(InputStream inputStream); }
Streams { public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException { byte buffer[] = new byte[BUFFER_SIZE]; int bytesRead = -1, totalBytesRead = 0; while ((bytesRead = inputStream.read(buffer)) >= 0) { totalBytesRead += bytesRead; outputStream.write(buffer, 0, bytesRead); } } private  Streams(); static void copy(InputStream inputStream, OutputStream outputStream); static ByteArrayOutputStream read(InputStream inputStream);  }