StreamUtil { public static InputStream makeCopy(InputStream input) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); copyStream(input, out); return new ByteArrayInputStream(out.toByteArray()); }  static File createFile(InputStream input, int expected); static File createFile(InputStream input, int expected, String dir); static void copyStream(InputStream input, OutputStream output,
                                int expected); static void copyStream(InputStream input, OutputStream output); static InputStream makeCopy(InputStream input); static void copyAndClose(InputStream input, Writer out); static void copyAndClose(InputStream input, Writer out, Charset charset); static void copyAndClose(InputStream input, OutputStream out);  }
@Test public void testMakeCopy() throws Exception { ByteArrayInputStream in = new ByteArrayInputStream(TEXT.getBytes()); InputStream in2 = StreamUtil.makeCopy(in); ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(in2, out); assertEquals(TEXT, out.toString()); }