Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to use file filter to list files
public File[] getListOfDirectories(File folder){
FileFilter directoryFileFilter = new FileFilter(){
@Override
public boolean accept(File pathname) {
for(File file: pathname.listFiles()){
if(file.isDirectory() && file.getName().contains("Collection")){
return true;
}
}
return false;
}
};
File[] reportFolderDirectories = folder.listFiles(directoryFileFilter);
return reportFolderDirectories;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment