I guess, you have to implement your own FileFilter.
Something like this:
class CustomDirectoryFilter implements FileFilter {
private String allowedFileName = "testFolder";
@Override
public boolean accept(File pathname) {
if (pathname.isDirectory()) {
File[] subFiles = pathName.listFiles();
for (File file : subFiles){
if (file.getName().equals(allowedFileName)){
return true;
}
}
}
return false;
}
}
Explanation: for each file from C:\myHomeDirectory test if given file is directory. If it is, get array of all files in it and test, if any of these files contains your file. If such file found, allow the directory to be part of myDirectories
I have no chance to test if this example code compiles now, but I hope it helps you to get your solution.