I am trying to get the files and folders recursively in an ArrayList using threads, since the program if what I'm looking for has many files and directories remains frozen until it ends and I do not know very well what I have to do, this is the wireless code, working, I hope someone can explain how to do it.
public static void main(String[] args) {
FilenameFilter textFilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
String lowercaseName = name.toLowerCase();
if (lowercaseName.contains("prueba")) {
return true;
} else {
return false;
}
}
};
ArrayList<File> archivos = new ArrayList(busqueda(new File(ruta),textFilter,true));
}
public static Collection busqueda(File directorio, FilenameFilter filtro, boolean recursivo) {
Vector archivos = new Vector();
File[] entries = directorio.listFiles();
for (File entry : entries) {
if (filtro == null || filtro.accept(directorio, entry.getName())) {
archivos.add(entry);
}
if (recursivo && entry.isDirectory()) {
archivos.addAll(busqueda(entry, filtro, recursivo));
}
}
return archivos;
}