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();
}

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 ( ) ; }
read a stream into a byte [ ] . < p > note : the stream is closed as a side - effect .
