public void writeBytes(final byte[] bytes) throws IOException {
    final byte[] finalBytes;
    if (compressed) {
      finalBytes = Snappy.compress(bytes);
    } else {
      finalBytes = bytes;
    }
    int pos = currentSize;
    currentSize += finalBytes.length;
    if (currentSize > MAX_FILE_SIZE) {
      out.close();
      out = new FileOutputStream(filenameGenerator.apply(++fileNumber, compressed).toFile());
      currentSize = finalBytes.length;
      pos = 0;
    }
    index.writeShort(fileNumber);
    index.writeInt(pos);
    out.write(finalBytes);
  }
Write bytes.

@param bytes the bytes
@throws IOException the io exception
util/src/main/java/org/hyperledger/besu/util/io/RollingFileWriter.java