[ https://issues.apache.org/jira/browse/IO-531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15976384#comment-15976384 ]
Sebb commented on IO-531: ------------------------- The PDF says: {quote} I want to use the org.apache.commons.io.FileUtils.listFiles(File, IOFileFilter, IOFileFilter) api to list all the files except the files in subdirectory “se” {quote} That could be coded as: {code} FileUtils.listFiles(directory, TrueFileFilter.TRUE, new NotFileFilter(new NameFileFilter("se"))) {code} Note that you can also subclass AbstractFileFilter as follows: {code} new AbstractFileFilter() { @Override public boolean accept(File file) { return ! file.getName().contains("se"); } } {code} No need to check if the file is a directory as the dirfilter is only called for directories. or you could use {code} new AbstractFileFilter() { @Override public boolean accept(File dir, String name) { return ! name.contains("se"); } } {code} Both would be closer to the solutions shown in the PDF which check for "se" in the directory name > make it more esay-to-use: org.apache.commons.io.FileUtils.listFiles(File, > IOFileFilter, IOFileFilter) > ----------------------------------------------------------------------------------------------------- > > Key: IO-531 > URL: https://issues.apache.org/jira/browse/IO-531 > Project: Commons IO > Issue Type: Improvement > Components: Utilities > Affects Versions: 2.5 > Reporter: Hao Liu > Attachments: Commons IOIO-531.pdf > > > when I only want to filter the directories, it should be better to allow me > to set the second parameter to null or I have to implement the > org.apache.commons.io.filefilter.IOFileFilter interface with nothing > functionally task to do. -- This message was sent by Atlassian JIRA (v6.3.15#6346)