Java



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 files in the specified folder. As the hierarchy is being traversed, the names of the subfolders or files are being displayed in an indented fashion where the amount of indentation reflects the hierarchy level of the displayed subfolders or files. This command should produce an output similar to the tree command in the DOS operating system. The figure below shows a display of a partial output of the tree command. Students
can experiment with this command by typing tree
The Java API provides the File class which can be used to implement this assignment