0

I'm using Apache Commons VFS2.0 to access files both in a local file system and a remote file system. I'm trying to find a way to filter all the descendent files in any depth with FileType=File and has a given filePrefix with the file name. I was able to do it for the same case except for file prefix, but for file extension, as follows.

FileSelector fileSelector = new FileExtensionSelector("extensions...");
directory.findFiles(fileSelector);

In this way, I was able to fetch all the files(no folders) in any depth with the given extension. I have tried the below approach but it only works for matching files with depth=1.

FileFilterSelector prefixFileSelector = new FileFilterSelector(new PrefixFileFilter("Prefix"));
directory.findFiles(prefixFileSelector);

Appreciate if anyone can give a suggestion.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
ThilankaD
  • 1,021
  • 1
  • 13
  • 24

1 Answers1

0
new FileFilterSelector(fileFilter) {
    @Override
    public boolean traverseDescendents(FileSelectInfo fileInfo) {
        return true;
    }

    @Override
    public boolean includeFile(FileSelectInfo fileInfo) throws Exception {
        return accept(fileInfo);
    }
}
Miss Chanandler Bong
  • 4,081
  • 10
  • 26
  • 36
vladkabat
  • 1
  • 3