code: public int read(long pos, byte[] b, int off, int len) {
      // since max is len (an int), result is guaranteed to be an int
      int bytesToRead = (int) bytesToRead(pos, len);
  
      if (bytesToRead > 0) {
        int remaining = bytesToRead;
  
        int blockIndex = blockIndex(pos);
        byte[] block = blocks[blockIndex];
        int offsetInBlock = offsetInBlock(pos);
  
        int read = get(block, offsetInBlock, b, off, length(offsetInBlock, remaining));
        remaining -= read;
        off += read;
  
        while (remaining > 0) {
          int index = ++blockIndex;
          block = blocks[index];
  
          read = get(block, 0, b, off, length(remaining));
          remaining -= read;
          off += read;
        }
      }
  
      return bytesToRead;
    }
docs: Reads up to {@code len} bytes starting at position {@code pos} in this file to the given byte
  array starting at offset {@code off}. Returns the number of bytes actually read or -1 if {@code
  pos} is greater than or equal to the size of this file.