I want to collect all the (sub) directories in the directory corresponding to the name using Apache IO Commons. Although I can solve this problem for files using NameFileFilter
in combination with FileUtils.listFiles
, I can not find a solution for this for folders.
I tried the following snippet:
IOFileFilter fileFilter = new NameFileFilter(fileName);
Collection<File> fileList = FileUtils.listFilesAndDirs(rootFolder, fileFilter, TrueFileFilter.INSTANCE);
It identifies folders and subfolders, but does not filter them according to NameFileFilter. What am I doing wrong?
source
share