question: protected static byte [ ] read ( InputStream is ) throws IOException { final boolean close = true ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; try { int i ; while ( ( i = is . read ( ) ) != - 1 ) { baos . write ( i ) ; } } finally { try { if ( close ) { is . close ( ) ; } baos . close ( ) ; } catch ( Exception ex ) { log . warn ( "Could not close input/output stream: " + ex , ex ) ; } } return baos . toByteArray ( ) ; }
target:  Read a stream into a byte[]. <p> Note: The stream is closed as a side-effect.