/**
  * This function displays 5KB of a file from a specific offset if it is in ASCII format.
  *
  * @param path The path of the file to display
  * @param request The HttpServletRequest object
  * @param offset Where the file starts to display.
  * @throws FileDoesNotExistException
  * @throws IOException
  * @throws InvalidPathException
  */
 private void displayFile(String path, HttpServletRequest request, long offset)
     throws FileDoesNotExistException, InvalidPathException, IOException {
   String masterAddress =
       Constants.HEADER
           + mMasterInfo.getMasterAddress().getHostName()
           + ":"
           + mMasterInfo.getMasterAddress().getPort();
   TachyonFS tachyonClient = TachyonFS.get(masterAddress);
   TachyonFile tFile = tachyonClient.getFile(path);
   String fileData = null;
   if (tFile == null) {
     throw new FileDoesNotExistException(path);
   }
   if (tFile.isComplete()) {
     InStream is = tFile.getInStream(ReadType.NO_CACHE);
     int len = (int) Math.min(5 * Constants.KB, tFile.length() - offset);
     byte[] data = new byte[len];
     is.skip(offset);
     is.read(data, 0, len);
     fileData = CommonUtils.convertByteArrayToStringWithoutEscape(data);
     if (fileData == null) {
       fileData = "The requested file is not completely encoded in ascii";
     }
     is.close();
   } else {
     fileData = "The requested file is not complete yet.";
   }
   try {
     tachyonClient.close();
   } catch (IOException e) {
     LOG.error(e.getMessage());
   }
   List<BlockInfo> rawBlockList = mMasterInfo.getBlockList(path);
   List<UiBlockInfo> uiBlockInfo = new ArrayList<UiBlockInfo>();
   for (BlockInfo blockInfo : rawBlockList) {
     uiBlockInfo.add(new UiBlockInfo(blockInfo));
   }
   request.setAttribute("fileBlocks", uiBlockInfo);
   request.setAttribute("fileData", fileData);
 }