Assignment: Directory Tree
In this assignment, students are required to implement an operating system command that displays the tree structure of a folder or directory. The program asks the user to enter a folder name. Next, the program traverses the tree hierarchy of this folder in a preorder traversal to retrieve the children folders or ?les in the speci?ed folder. As the hierarchy is being traversed, the names of the subfolders or ?les are being displayed in an indented fashion where the amount of indentation re?ects the hierarchy level of the displayed subfolders or ?les. This command should produce an output similar to the tree command in the DOS operating system. The ?gure below shows a display of a partial output of the tree command. Students can experiment with this command by typing tree | more
The Java API provides the File class which can be used to implement this assignment.