0

I am trying to get all subdirectories that have "messages_" in the name using FileUtils

Collection<File> filesToRead = FileUtils.listFiles(new File(fromDirectory),
        new DirectoryFileFilter() {
            @Override
            public boolean accept(File dir, String name) {
                if (dir.isDirectory() && dir.getName().contains("messages_")){
                    return true;
                }
                return false;
            }
        }, TrueFileFilter.INSTANCE);

This is not working for me. How to achieve this using FileUtils?

trailblazer
  • 1,421
  • 5
  • 20
  • 43

1 Answers1

0
Collection<File> filesToRead = FileUtils.listFilesAndDirs(new File(fromDirectory),
        FalseFileFilter.INSTANCE, // exclude files
        new WildcardFileFilter("*messages_*") // folders filter
);
Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417