CS 173 Introduction to Computer Science II Spring 2019

Homework #6


The main goal of this project is to gain more familiarity with trees and file systems.


Starting with our LinkedTree.java and the FileStuff.java code, build a tree that starts at some folder location in a file system and builds a tree of objects for the files and directories (folders) in the file system subtree.

Create a new class that represents the information needed: The file path, the type of file (regular or directory), and size. You might also want to include the depth of each node.

Create a new class that uses the LinkedTree class. Provide a constructor that takes a String representing the root directory and builds the tree. Include a toString method that prints a breadth-first traversal of the file system tree.

Your code should be general enough to work on any starting directory on computer system, not just windows or mac, so use the proper separator character.

Demonstrate this by printing out a breadth-frst traversal of the file system tree. Include the full File pathname. If the File is a regular file, also print the size. If the File is a directory, print the number of Files and the total size of all the Files rooted at that node of the tree.

Copyright © 2019, David A. Reimann. All rights reserved.