public static byte[] readBytesAndClose(InputStream in,int length) throws IOException {
  try {
    if (length <= 0) {
      length=Integer.MAX_VALUE;
    }
    int block=Math.min(Constants.IO_BUFFER_SIZE,length);
    ByteArrayOutputStream out=new ByteArrayOutputStream(block);
    copy(in,out,length);
    return out.toByteArray();
  }
 catch (  Exception e) {
    throw DbException.convertToIOException(e);
  }
 finally {
    in.close();
  }
}

public static byte [ ] readBytesAndClose ( InputStream in , int length ) throws IOException { try { if ( length <= 0 ) { length = Integer . MAX_VALUE ; } int block = Math . min ( Constants . IO_BUFFER_SIZE , length ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( block ) ; copy ( in , out , length ) ; return out . toByteArray ( ) ; } catch ( Exception e ) { throw DbException . convertToIOException ( e ) ; } finally { in . close ( ) ; } }
read a number of bytes from an input stream and close the stream .
