question: private static byte [ ] toByteArray ( InputStream inputStream ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; byte buffer [ ] = new byte [ 8192 ] ; while ( true ) { int read = inputStream . read ( buffer ) ; if ( read == - 1 ) { break ; } baos . write ( buffer , 0 , read ) ; } return baos . toByteArray ( ) ; }
target:  Fully reads the given InputStream and returns it as a byte array