Description
The new RegexFileFilter.accept(Path, BasicFileAttributes) uses the full path for matching. When this filter is used in combination with FileUtils.listFiles(File, IOFileFilter, IOFileFilter), then it will not match anything if a path separator is not part of the pattern.
The following small program will list all files when used with version 2.8.0 and nothing when used with version 2.9.0:
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.*;
import java.io.File;
import java.util.Collection;
class ListFilesRegexBug {
public static void main(String[] args) {
RegexFileFilter filter = new RegexFileFilter("[^/\\\\]+");
Collection<File> files = FileUtils.listFiles(new File("."), filter, TrueFileFilter.TRUE);
for (File f : files) {
System.out.println(f.getAbsolutePath());
}
}
}
Attachments
Attachments
Issue Links
- duplicates
-
IO-733 RegexFileFilter uses the path and file name instead of just the file name.
- Closed