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 pathname) | The constructor takes a pathname and creates a File object corresponding to the file or directory with that pathname. |
String getAbsolutePath() | Returns the pathname of the File object, e.g., C:\Papers\TermPaper.odt |
String getName() | Returns the name of the File object, e.g., TermPaper.odt |
boolean isDirectory() | Tests whether the File object is a directory. |
File[] listFiles() | If the File object is a directory then this returns an array of File objects corresponding to all the items within the directory. |
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, ""
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.