Question: File Searching Homework CSS 143: Programming Methodology Instructor Lesley Kalmin Assignment by Rob Nash Introduction & Driver In this assignment, your job is to write


File Searching Homework CSS 143: Programming Methodology Instructor Lesley Kalmin Assignment by Rob Nash Introduction & Driver In this assignment, your job is to write a class that searches through a file hierarchy (a treel for a specified file. Your EindElle,class will search a directory (and all subdirectories) for a target file name. For example, in the file hierarchy pictured above, the file Tesson.ess" will be found once in a directory near the root or top-level drive name leg. "C Your FindFile class will start at the path indicated and will search eath directory and subdirectory looking for a file match. Consider the following code that could help you build your Driver java: Recursively Searching Files&Directories Summary Build a class and a driver for use in searching your computer's secondary storage (hard disk or flash memory) for a specific file from a set of files indicated by a starting path. Lets start by looking at a directory listing. Note that every element is either a file or a directory. String tareetis "lesson.css" String pathTesearch CAUWCWS Find File finder: new Find File MAX NUMBER OF FILES TO FIND): Finder.directorySearchitargetFile, eathTosearch) File Searching In general, searching can take multiple forms depending on the structure and order of the set to search. If we can make promises about the data (this data is sorted, or deltas vary by no more than 10, etc.), then we can leverage those constraints to perform a more efficient search. Files in a file system are exposed to clients of the operating system and can be organized by filename, file ereation date, size, and a number of other properties. We'll just be interested in the file names here, and we'll want perform a brute force (ie sequential) search of these files looking for a specific file. The way in which we'll get file information from the operating system will involve no ordering; as a result, a linear search is the best we can do. We'd like to search for a target file given a specified path and return the location of the file, if found. You should sketch out this logie linearly before attempting to tackle it recursively Authoring ?ExternaFile.xsd lesson.css ? lesson.ji Template.html courseSourceFiles Category ClassFiles Demos Exercises Solutions FindFile Class Interface: Findfilelint maxFiles) o This constructor accepts the maximum number of files to find. Demos * void directorvsearchiString target, String dicName Exercises Solutions The parameters are the target file name to look for and the directory to stant in. o = Setup nt etCount ReadMe.html WCW101.html o This accessor returns the number of matching files found o This getter returns the array of file locations, up to maxfiles in size Manual ? Images LessonName1.htm ?LessonName2.html
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
