Problem

A description of the File class is available on Oracle’s Java Web site at http:// docs.ora...

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, ""

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT