private void checkOrReallocateBuffer(int length) throws OutOfBlockBufferMemoryException {
  if (size + length <= capacity) {
    return;
  }
  if (exposedSlices) {
    throw new OutOfBlockBufferMemoryException();
  }
  capacity=(size + length) * 2;
  byte[] oldBuffer=buffer;
  buffer=new byte[capacity];
  if (size > 0) {
    System.arraycopy(oldBuffer,0,buffer,0,size);
  }
}

private void checkOrReallocateBuffer ( int length ) throws OutOfBlockBufferMemoryException { if ( size + length <= capacity ) { return ; } if ( exposedSlices ) { throw new OutOfBlockBufferMemoryException ( ) ; } capacity = ( size + length ) * 2 ; byte [ ] oldBuffer = buffer ; buffer = new byte [ capacity ] ; if ( size > 0 ) { System . arraycopy ( oldBuffer , 0 , buffer , 0 , size ) ; } }
check the buffer size and reallocate if buffer is not enough
