private static StringBuilder printContentsOfDir(String dir, int depth, StringBuilder sb) {
    StringBuilder indent = new StringBuilder();
    for(int i = 0; i < depth; i++) {
      indent.append("--");
    }
    File folder = new File(dir);
    sb.append(indent).append("Files in '").append(dir).append("' dir:").append(folder.getAbsolutePath()).append('\n');

    File[] listOfFiles = folder.listFiles();
    if(listOfFiles == null) {
      return sb;
    }
    for (File fileName : listOfFiles) {
      if (fileName.isFile()) {
        sb.append(indent).append("File: ").append(fileName.getName()).append('\n');
      }
      else if (fileName.isDirectory()) {
        printContentsOfDir(fileName.getName(), depth+1, sb);
      }
    }
    return sb;
  }
Print files and directories in current {@code dir}.
hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/TrivialExecService.java