Follow these steps to implement the example:
- Create a class called FileSearch and specify that it implements the Runnable interface:
public class FileSearch implements Runnable {
- Declare two private attributes: one for the name of the file we are going to search for and one for the initial folder. Implement the constructor of the class, which initializes these attributes:
private String initPath; private String fileName; public FileSearch(String initPath, String fileName) { this.initPath = initPath; this.fileName = fileName; }
- Implement the run() method of the FileSearch class. It checks whether the attribute fileName is a directory; if it is, it calls the directoryProcess() method. This method can throw an ...