You can do a simple recursive function with File.listFiles()
method
public Collection<File> findDir(File dir, String name) {
ArrayList<File> result = new ArrayList<File>();
if(!dir.isDirectory()) return result;
for(File child : dir.listFiles()) {
if(child.getName().equals(name)) result.add(child);
result.addAll(findDir(child, name));
}
return result;
}
Assuming you want to find all z1
directory inside C:\projects\workspace\testing
then:
Collection<File> result = findDir(new File("C:/projects/workspace/testing"), "z1");