I am trying to make a Java program that uses a tree to collect folder and file information about a directory and display it to the user. Essentially a java version of the tree DOS command.
The user inputs a path to a folder and the command window will spit out all the files and folders under that path. I am using a recursive preorder (root first) tree traversal to retrieve the child folders or files in desired path.
My main just retrieves the desired folder and calls the method:
System.out.print("Enter a folder name: ");
Scanner in = new Scanner (System.in);
String folder = in.nextLine();
File folder = new File(folder);
What I am having trouble with is the tree. It isn't binary so I can't know the maximum size based on the depth. I figured it would be easiest to display the next folder/file as I am traversing. Any advice on how to iterate a tree to do this?