public StoreFileChunk readStoreFileChunkFromDisk(String fileName, long offset, long size, boolean isChunked)
      throws StoreException, IOException {
    // Verify service is running before proceeding
    validateIfFileStoreIsRunning();

    File file = validateAndGetFile(fileName);
    if (!isChunked) {
      return new StoreFileChunk(new DataInputStream(Files.newInputStream(file.toPath())), file.length());
    }
    try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r")) {
      // Verify if offset + size is lesser than the filesize to avoid EOF exceptions
      if (offset + size > randomAccessFile.length()) {
        throw new IndexOutOfBoundsException("Read offset and size exceeds the filesize for file: " + fileName);
      }
      // Seek to the specified offset
      randomAccessFile.seek(offset);

      // Allocate buffer for reading data
      ByteBuffer buf = ByteBuffer.allocate((int) size);

      // Read data into buffer. Looping since read() doesn't guarantee reading all bytes in one go.
      while (buf.hasRemaining()) {
        int bytesRead = randomAccessFile.getChannel().read(buf);
        if (bytesRead == -1) {
          break; // EOF reached
        }
      }
      // Prepare buffer for reading
      buf.flip();
      // return file chunk buffer read
      return StoreFileChunk.from(buf);
    } catch (FileNotFoundException e) {
      throw new StoreException("File not found while reading chunk for FileCopy", e, StoreErrorCodes.FileNotFound);
    } catch (IOException e) {
      StoreErrorCodes errorCode = StoreException.resolveErrorCode(e);
      throw new StoreException(errorCode.toString() + "while reading chunk for FileCopy", e, errorCode);
    } catch (Exception e) {
      logger.error("Error while reading chunk from file: {}", fileName, e);
      throw new FileStoreException("Error while reading chunk from file: " + fileName, e,
          FileStoreErrorCode.FileStoreReadError);
    }
  }
Reads a portion of a file into a StoreFileChunk object
@param fileName The name of the file to read
@param offset   The starting position in the file
@param size     The number of bytes to read
@return StoreFileChunk containing the requested data
@throws StoreException        if there are issues reading the file
ambry-store/src/main/java/com/github/ambry/store/FileStore.java