A description of the File class is available on Oracles Java Web site at http:// docs.oracle.com/javase/7/docs/api/java/io/File.html. To

Question:

A description of the File class is available on Oracle’s Java Web site at http:// docs.oracle.com/javase/7/docs/api/java/io/File.html. To use this class you must import java.io.File. For this program the relevant methods of the File class are described below:

File (String The constructor takes a pathname and creates a File object pathname) corresponding to the file or directory with that pathname. String Returns the pathname of the File object, e.g., getAbsolute Path () C:\Papers\TermPaper.odt string getName () Returns the name of the File object, e.g., TermPaper.odt boolean Tests whether


Write the static recursive method String searchForFile(File currentFolder, String filename). The first parameter should be a File object that specifies the root folder to search for the file named filename. The method should recursively search all subfolders for the file and return the complete pathname to the first match. For example, if currentFolder is set to C:\ and filename is “foo.txt” then it might return “C:\Code\Stuff\foo.txt” if that is a valid pathname for the file. If there is no file with a matching name within the currentFolder then the method should return a blank string, “”.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: