code: private long fileSizeAdjusted(long alignedPointerToRaw, long readSize) {
          // end of section outside the file --> cut at file.length()
          if (readSize + alignedPointerToRaw > file.length()) {
              readSize = file.length() - alignedPointerToRaw;
          }
          // start of section outside the file --> nothing is read
          if (alignedPointerToRaw > file.length()) {
              logger.info("invalid section: starts outside the file, readsize set to 0");
              readSize = 0;
          }
          return readSize;
      }
docs: Adjusts the readsize of a section to the size of the file.
  
  @param alignedPointerToRaw
  the file offset of the start of the section
  @param readSize
  the determined readsize without file adjustments
  @return adjusted readsize