code: public void write(byte[] b, int off, int len) throws IOException {
      // Sanity checks
      if (compressor.finished()) {
        throw new IOException("write beyond end of stream");
      }
      if (b == null) {
        throw new NullPointerException();
      } else if ((off < 0) || (off > b.length) || (len < 0) ||
                 ((off + len) > b.length)) {
        throw new IndexOutOfBoundsException();
      } else if (len == 0) {
        return;
      }
  
      long limlen = compressor.getBytesRead();
      if (len + limlen > MAX_INPUT_SIZE && limlen > 0) {
        // Adding this segment would exceed the maximum size.
        // Flush data if we have it.
        finish();
        compressor.reset();
      }
  
      if (len > MAX_INPUT_SIZE) {
        // The data we're given exceeds the maximum size. Any data
        // we had have been flushed, so we write out this chunk in segments
        // not exceeding the maximum size until it is exhausted.
        rawWriteInt(len);
        do {
          int bufLen = Math.min(len, MAX_INPUT_SIZE);
          
          compressor.setInput(b, off, bufLen);
          compressor.finish();
          while (!compressor.finished()) {
            compress();
          }
          compressor.reset();
          off += bufLen;
          len -= bufLen;
        } while (len > 0);
        return;
      }
  
      // Give data to the compressor
      compressor.setInput(b, off, len);
      if (!compressor.needsInput()) {
        // compressor buffer size might be smaller than the maximum
        // size, so we permit it to flush if required.
        rawWriteInt((int)compressor.getBytesRead());
        do {
          compress();
        } while (!compressor.needsInput());
      }
    }
docs: Write the data provided to the compression codec, compressing no more
  than the buffer size less the compression overhead as specified during
  construction for each block.
  
  Each block contains the uncompressed length for the block, followed by
  one or more length-prefixed blocks of compressed data.