Starting from:

$15

Largest File on Disk

You are going to write a program that uses your new expertise in recursion to explore a directory on a user’s computer. When your computer (or rather the hard drive that you are using) is running out of space, it might be hard to find the large files scattered all over your directory structure. Your program will provide a tool that given a name of a directory, explores all its sub-directories and files and does two things: computes the total size of all the files and sub-directories, prints a list of n largest files (their sizes and absolute paths. The program that you write has to be command line based (no graphical interface) and it should not be interactive (donot ask user for anything). Objectives The goal of this programming project is for you to master (or at least get practice on) the following tasks: developing and writing recursive algorithms, working with existing code, using classes and methods that are part of the Java API, using command line arguments, implementing classes according to provided specification. The Program Input and Output Input The program should take two command line arguments. First one is a directory name. If the directory is omitted from the command line, it is an error. The program should display an error message and terminate. The error message should indicate what went wrong. If the directory name is provided, but it is not a name of a valid directory, the program should display an error message and terminate. The error message should indicate what went wrong. The second one is the maximum number of largest files found in the directory provided as the first argument. If the number is missing, the default value of 20 should be used. Output Your program should determine and print to standard output the total space used by the directory in question (that includes the sizes or all the files and subdirectories contained in it). The program should also print the sizes and pathnames of the largest files.

More products