Programming Assignment

CPSC 231: Computer Science II

Spring 2018

Programming Assignment 6: A File System Browser

Due: Apr. 23rd, 2018. 11:59pm

Reading

This assignment assumes you have read Ch. 9 and 10 of the Savitch book.

The Assignment

We’ll continue working with file IO and exception handling by building a simple text-based interface for browsing the file system.

When your program starts it should ask the user if they would like to dump results to a log file IN ADDITION to standard out. If so, your program should prompt for the name of the log file. If the file already exists, the contents should be overwritten.

The program will then display (6) options to the user:

List the contents of a directory provided by the user

List the contents of a directory provided by the user as well as all of its sub directories. (hint: use recursion)

Locate a file with a given name.

Locate files with a given file extension

Concatenate the contents of 2 files whose names are provided by the user and output the result to a third file (name also provided by the user) 6) Exit

You should refer to the File class API provided in the java.io package.

Extra Credit

Up to 10% extra credit will be awarded to programs who provide additional (useful) options in addition to those listed above. For example, locating files based on regular expression matches in the file name or the file content.

Also, Up to 10% extra credit will be awarded to programs who provide a GUI for the program described.

Be creative. Have fun.

Due Date

This assignment is due at 11:59pm on 04-23-2018. Submit it to Blackboard following the submission instructions available under “Content”. Please make sure to include all the required files.

NOTE: It would be best to have this assignment done by 04-19, as I will be posting assignment 7 at that time, but I will give you that last weekend free of penalty.

Grading

Assignments will be graded on correctness, elegance (following OO best practice), adherence to style conventions, and the inclusion of meaningful comments. Refer to “Content” on Blackboard for a link to a Java style guide.

Design

Make sure to design your program so that the file system functionality is encapsulated in its own class or classes. Specifically, you should design to that it would be trivial to hook up these features to a GUI rather than the command line (even if you aren’t doing the extra credit). (This means the main function should have almost no code in it, and that all command-line user interaction should be separate of file browsing implementation, etc.). Also, note that everything we go over in class IS expected to be applied to your assignments. Most notably, the clone method should be added to the list of things I have previously asked be in your classes.