package com.gmail.vhrushyn;
import java.io.File;
public class Searcher implements Runnable {
private File where;
private String name;
public Searcher(File where, String name) {
super();
this.where = where;
this.name = name;
}
private void MySearch() {
File[] files = where.listFiles();
for (File file : files) {
if (file.isDirectory()) {
Thread t = new Thread(new Searcher(file, name));
t.start();
}
if (file.getName().equalsIgnoreCase(name)) {
System.out.println(file.getPath());
}
}
}
public void run() {
MySearch();
}
}
package com.gmail.vhrushyn;
import java.io.File;
public class Main {
public static void main(String[] args) {
File where = new File("F:/Java"); // folder where to search
String name = "main.java"; // name of file to find
Thread t = new Thread(new Searcher(where, name));
t.start();
}
}