code: private void prepareToAddBytes(int numBytes) throws IOException {
  		if (buffer.remaining() < numBytes) {
  			buffer.flip();
  			channel.write(buffer);
  
  			int bufferCapacity = Math.max(BUFFER_SIZE, numBytes);
  			if (bufferCapacity != buffer.capacity()) {
  				ByteOrder order = buffer.order();
  				buffer = ByteBuffer.allocate(bufferCapacity);
  				buffer.order(order);
  			} else {
  				buffer.clear();
  			}
  		}
  	}
docs: Moves the window
  
  @param numBytes
  @throws java.io.IOException