code: private void writeBlock() throws IOException {
      if (buffer.position() == 0) {
        return;
      }
      // Make sure there's no stale data
      Arrays.fill(compressedBuffer, (byte) 0);
  
      int compressedLength = compressor.compress(buffer.array(), 0, buffer.position(), compressedBuffer, 0);
      final byte[] bufferToWrite;
      final int compressMethod;
  
      // Store block uncompressed if compressed length is greater (incompressible)
      if (compressedLength >= buffer.position()) {
        compressedLength = buffer.position();
        bufferToWrite = Arrays.copyOf(buffer.array(), compressedLength);
        compressMethod = LZ4_FRAME_INCOMPRESSIBLE_MASK;
      } else {
        bufferToWrite = compressedBuffer;
        compressMethod = 0;
      }
  
      // Write content
      intLEBuffer.putInt(0, compressedLength | compressMethod);
      out.write(intLEBuffer.array());
      out.write(bufferToWrite, 0, compressedLength);
  
      // Calculate and write block checksum
      if (frameInfo.isEnabled(FLG.Bits.BLOCK_CHECKSUM)) {
        intLEBuffer.putInt(0, checksum.hash(bufferToWrite, 0, compressedLength, 0));
        out.write(intLEBuffer.array());
      }
      buffer.rewind();
    }
docs: Compresses buffered data, optionally computes an XXHash32 checksum, and writes the result to the underlying
  {@link OutputStream}.
  
  @throws IOException