import java.io.File;
import java.util.Scanner;
public class DirectoryRecursion {
  /**
   * Entry point.
   */
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    System.out.println("Enter the name of the directory");
    String fullPath = scan.nextLine();
    File baseFile = new File(fullPath);
    listContents(baseFile);
  }

  /**
   * Displays the contents of a directory as a tree.
   * @param baseFile The directory to investigate
   */
  public static void listContents(File baseFile) {
    listContents(baseFile, 0);
  }

  /**
   * Displays the contents of a directory as a tree.
   * @param baseFile The directory to investigate
   * @param depth The current depth below the first directory
   */
  public static void listContents(File baseFile, int depth) {
    for (int i = 0; i < depth; i++) {
      System.out.print("  ");
    }
    System.out.println(baseFile.getName());
    if (!baseFile.isDirectory()) {
      return;
    }
    File[] contents = baseFile.listFiles();
    for (int i = 0; i < contents.length; i++) {
      listContents(contents[i], depth + 1);
    }
  }
}
