@Test public void testReadAllWithLargeSize() throws IOException { for (int i = 10; i <= 10000; i *= 10) { byte[] input = randomBytes(i); byte[] output = IO.readAll(new ByteArrayInputStream(input), i + 29); Assert.assertArrayEquals(input, output); } }
public static byte[] readAll(@WillClose InputStream in) throws IOException { try { ByteArrayOutputStream byteSink = new ByteArrayOutputStream(); copy(in, byteSink); return byteSink.toByteArray(); } finally { close(in); } }
IO { public static byte[] readAll(@WillClose InputStream in) throws IOException { try { ByteArrayOutputStream byteSink = new ByteArrayOutputStream(); copy(in, byteSink); return byteSink.toByteArray(); } finally { close(in); } } }
IO { public static byte[] readAll(@WillClose InputStream in) throws IOException { try { ByteArrayOutputStream byteSink = new ByteArrayOutputStream(); copy(in, byteSink); return byteSink.toByteArray(); } finally { close(in); } }  }
IO { public static byte[] readAll(@WillClose InputStream in) throws IOException { try { ByteArrayOutputStream byteSink = new ByteArrayOutputStream(); copy(in, byteSink); return byteSink.toByteArray(); } finally { close(in); } }  static byte[] readAll(@WillClose InputStream in); static byte[] readAll(@WillClose InputStream in, int size); static String readAll(Reader reader); static long copy(@WillNotClose InputStream in, @WillNotClose OutputStream out); static long copy(Reader in, Writer out); static long copy(@WillNotClose InputStream in, @WillNotClose OutputStream out, long maxBytes); static long copy(Reader in, Writer out, long maxChars); static void close(@CheckForNull AutoCloseable c); static void close(@CheckForNull Closeable c); static void close(@CheckForNull InputStream inputStream); static void close(@CheckForNull OutputStream outputStream); static void skipFully(InputStream in, long bytes); static boolean verifyURL(URL u); @CheckReturnValue @NonNull static URLConnection openNonCachedConnection(@NonNull URL u); @CheckReturnValue @NonNull static InputStream openNonCachedStream(@NonNull URL u); }
IO { public static byte[] readAll(@WillClose InputStream in) throws IOException { try { ByteArrayOutputStream byteSink = new ByteArrayOutputStream(); copy(in, byteSink); return byteSink.toByteArray(); } finally { close(in); } }  static byte[] readAll(@WillClose InputStream in); static byte[] readAll(@WillClose InputStream in, int size); static String readAll(Reader reader); static long copy(@WillNotClose InputStream in, @WillNotClose OutputStream out); static long copy(Reader in, Writer out); static long copy(@WillNotClose InputStream in, @WillNotClose OutputStream out, long maxBytes); static long copy(Reader in, Writer out, long maxChars); static void close(@CheckForNull AutoCloseable c); static void close(@CheckForNull Closeable c); static void close(@CheckForNull InputStream inputStream); static void close(@CheckForNull OutputStream outputStream); static void skipFully(InputStream in, long bytes); static boolean verifyURL(URL u); @CheckReturnValue @NonNull static URLConnection openNonCachedConnection(@NonNull URL u); @CheckReturnValue @NonNull static InputStream openNonCachedStream(@NonNull URL u);  }