IOUtils { public static String toString(InputStream input) throws IOException { if (input == null) { return null; } final InputStreamReader inputStreamReader = new InputStreamReader(input); final StringBuilder stringBuilder = new StringBuilder(); final char[] buffer = new char[BUFFER_SIZE]; int n = 0; while (EOF != (n = inputStreamReader.read(buffer))) { stringBuilder.append(buffer, 0, n); } return stringBuilder.toString(); } 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 testToString() throws IOException { final ByteArrayInputStream bios = new ByteArrayInputStream("test".getBytes()); Assert.assertEquals("test", IOUtils.toString(bios)); }