public static byte [ ] readBytesFromStream ( InputStream source , int bufferSize ) throws IOException { ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ; copyContentIntoOutputStream ( source , buffer , bufferSize , true ) ; return buffer . toByteArray ( ) ; }
read all bytes from an InputStream with the specified buffer size ; doesn t close input - stream