code: public void read (byte[] bytes, long storageIndex) throws IOException {
  
          long filePos = storageIndex / mFileSize;
          int storageOffset = (int) (storageIndex % mFileSize);
          byte[] cachedBytes = mCache.getIfPresent(filePos);
  
          File fileAtPos = new File(mBaseDir + File.separator + filePos);
          if (!fileAtPos.exists()) {
              fileAtPos.createNewFile();
              cachedBytes = new byte[mFileSize];
              Files.write(fileAtPos.toPath(), cachedBytes);
          } else if (cachedBytes == null) {
              cachedBytes = Files.readAllBytes(fileAtPos.toPath());
              mCache.put((int) filePos, cachedBytes);
          }
  
          if ((storageOffset + bytes.length) > mFileSize) {
              System.arraycopy(cachedBytes, storageOffset, bytes, 0, mFileSize - storageOffset);
              byte[] nextStep = new byte[bytes.length - (mFileSize - storageOffset)];
              read(nextStep, storageIndex + (mFileSize - storageOffset));
              System.arraycopy(nextStep, 0, bytes, mFileSize - storageOffset, nextStep.length);
          } else {
              System.arraycopy(cachedBytes, storageOffset, bytes, 0, bytes.length);
          }
  
      }
docs: Reading bytes from file
  
  @param bytes
  @param storageIndex
  @throws IOException