code: @Override
      public void displayFile(FileSystem fs, Path path, OutputStream outStream,
          int startLine, int endLine) throws IOException {
          if (logger.isDebugEnabled()) {
              logger.debug("displaying orc file:" + path.toUri().getPath());
          }
          StringBuilder ret = new StringBuilder();
          Reader orcreader = null;
          RecordReader reader = null;
          Object row = null;
          try {
              int lineNum = 1;
  
              orcreader = OrcFile.createReader(fs, path);
              reader = orcreader.rows(null);
              long endTime = System.currentTimeMillis() + STOP_TIME;
              while (reader.hasNext() && lineNum <= endLine
                  && System.currentTimeMillis() <= endTime) {
                  row = reader.next(row);
                  if (lineNum >= startLine) {
                      ret.append(String.format("Record %d:\n", lineNum));
                      String jsonString =
                          SerDeUtilsWrapper.getJSON(row,
                              orcreader.getObjectInspector());
                      try {
                          JSONObject jsonobj = new JSONObject(jsonString);
                          ret.append(jsonobj.toString(JSON_INDENT));
                      } catch (JSONException e) {
                          logger.error("Failed to parse json as JSONObject", e);
                          // default to unformatted json string
                          ret.append(jsonString);
                      }
                      ret.append("\n\n");
                  }
                  lineNum++;
              }
              outStream.write(ret.toString().getBytes(StandardCharsets.UTF_8));
          } catch (IOException e) {
              outStream.write(("Error in display orc file: " + e
                  .getLocalizedMessage()).getBytes("UTF-8"));
              throw e;
          } finally {
              if (reader != null) {
                  reader.close();
              }
          }
      }
docs: Reads orc file and write to outputstream in json format {@inheritDoc}
  
  @throws IOException
  @throws
  
  @see HdfsFileViewer#displayFile(org.apache.hadoop.fs.FileSystem,
  org.apache.hadoop.fs.Path, OutputStream, int, int)