private void save() throws IOException {
    // if there's nothing to save don't do anything
    if (blockOutputStream.size() == 0) {
      return;
    }
    // write and increment the block sequence no
    writeInt(nextSequenceNumber++);

    // calculate the hash of the buffer
    byte[] buffer = blockOutputStream.toByteArray();
    md.update(buffer);
    outputStream.write(md.digest());

    // write the buffer's length
    writeInt(buffer.length);

    // write the buffer
    outputStream.write(buffer);

    // push the contents to disk etc.
    outputStream.flush();

    // reset the internal output buffer for reuse
    blockOutputStream.reset();
  }
private void save()