IOUtil { public static void copy(@NonNull InputStream input, @NonNull OutputStream output) throws IOException { final byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = input.read(buffer)) != -1) { output.write(buffer, 0, bytesRead); } output.flush(); }  static void copy(@NonNull InputStream input, @NonNull OutputStream output); static String toString(@NonNull InputStream input);  }
@Test public void copy() throws IOException { InputStream is = new ByteArrayInputStream("BASE".getBytes()); ByteArrayOutputStream os = new ByteArrayOutputStream(); IOUtil.copy(is, os); assertEquals("BASE", os.toString()); }