private @NotNull CheckerOutputStream buildOldComparerStream(final int startingOffsetInFile) throws IOException {
    final PagedFileStorage storage = this.storage.getPagedFileStorage();

    if (fileLength <= startingOffsetInFile) {
      return new CheckerOutputStream() {
        private int address = startingOffsetInFile - fileLength;

        @Override
        public void write(int b) {
          if (same) {
            same = address < AppendMemoryBuffer.getBufferPosition(appendBuffer) && appendBuffer.getAppendBuffer()[address++] == (byte)b;
          }
        }
      };
    }
    else {
      return new CheckerOutputStream() {
        private int offsetInFile = startingOffsetInFile;
        private int offsetInPage = storage.getOffsetInPage(startingOffsetInFile);
        private DirectBufferWrapper buffer = storage.getByteBuffer(startingOffsetInFile, false);
        private final int pageSize = storage.getPageSize();

        @Override
        public void write(int b) throws IOException {
          if (same) {
            if (offsetInPage == pageSize) {    // reached end of current page
              offsetInFile = ((offsetInFile / pageSize) + 1) * pageSize;
              if (offsetInFile >= fileLength) {
                same = false;
                return;
              }

              buffer.unlock();
              buffer = storage.getByteBuffer(offsetInFile, false);
              offsetInPage = 0;
            }

            same = buffer.get(offsetInPage, true) == (byte)b;
            offsetInPage++;
          }
        }

        @Override
        public void close() {
          buffer.unlock();
        }
      };
    }
  }
private @NotNull CheckerOutputStream buildOldComparerStream(final int startingOffsetInFile)