Description of this paper

Write methods for sorting the contents of the Vector




package directoryLister.template;import;import java.text.SimpleDateFormat;import java.util.Date;import java.util.Vector;import javax.swing.JOptionPane;/**;* DirectoryLister class.;* This class allows the user to recursively display the contents of a;* selected directory in the file system.;*/;public class DirectoryLister;// -----------------------------------------------------------------------;// Constants;// -----------------------------------------------------------------------;// -----------------------------------------------------------------------;// Attributes;// -----------------------------------------------------------------------;/** GUI used to display results */;private GUI gui;/** base path of directory to be traversed */;private String basePath;/** Vector of Vectors to store the information for the files/subfolders of the selected folder */;// TODO;// -----------------------------------------------------------------------;// Constructors;// -----------------------------------------------------------------------;/**;* Create a new DirectoryLister that uses the specified GUI.;*/;public DirectoryLister(GUI gui);this.gui = gui;// -----------------------------------------------------------------------;// Methods;// -----------------------------------------------------------------------;/**;* Allow user to select a directory for traversal.;*/;public void selectDirectory();// clear results of any previous traversal;gui.resetGUI();// allow user to select a directory from the file system;basePath = gui.getAbsoluteDirectoryPath();if (basePath != null);// update the address label on the GUI;gui.setAddressLabelText(basePath);// traverse the selected directory, and display the contents;showDirectoryContents(basePath);/**;* Show the directory listing.;* An error message is displayed if basePath does not represent a valid directory.;*;* @param basePath the absolute path of a directory in the file system.;*/;public void showDirectoryContents(String basePath);// TODO;// This method should function exactly as it did in the Module 3 assignment;// except after the selected directory has been enumerated, the contents should be;// sorted in ascending order based on the path of the files/subfolders.;/**;* Recursive method to enumerate the contents of a directory.;* The results of the enumeration are stored in the Vector folderContents.;*;*;* @param f directory to enumerate;*/;private void enumerateDirectory(File f);// TODO;// This method should function similarly to the way it did for the Module 3 assignment, with;// the following exception;//;// Instead of updating the GUI as before, the contents of each file or folder should be placed;// into a Vector of size 4. This Vector should then be added to the Vector "folderContents;// which has been declared as an attribute of this class.;//;// The Vector folderContents is a Vector of Vectors, where each Vector represents the;// information for each file/folder and occupies a single row in the table.;//;// Information is stored within each row in the following order;//;// Column 1: absolute path of file or folder, as a String;// Column 2: size of file in kilobytes, or -1 for folders, as a long value;// Column 3: type - "File" or "Folder", as a String;// Column 4: date last modified, in milliseconds;// TODO;//;// Write methods for sorting the contents of the Vector "folderContents" in ascending and;// descending order, using the specified column of data as the basis for the sort.


Paper#64316 | Written in 18-Jul-2015

Price : $29