public static byte [ ] copyToByteArray ( InputStream in ) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream ( BUFFER_SIZE ) ; copy ( in , out ) ; return out . toByteArray ( ) ; }
Copy the contents of the given InputStream into a new byte array . Closes the stream when done .