Jakarta Commons IO file filters

E

elektrophyte

Has anybody worked with the Jakarta Commons IO File utilities? I am
trying to get an ArrayList of Files with names that match a String. I'm
searching recursively in a directory and subdirs.

Here is my code:

Collection docs = FileUtils.listFiles(
documentDir,
FileFilterUtils.nameFileFilter(filterString),
TrueFileFilter.INSTANCE);

The Collection "docs" always winds up with nothing in it.

Any help would be greatly appreciated.

Thanks,

E
 
R

Roedy Green

Collection docs = FileUtils.listFiles(
documentDir,
FileFilterUtils.nameFileFilter(filterString),
TrueFileFilter.INSTANCE);

I wrote my own set of filters. You are free to use them. See
http://mindprod.com/products1.html#FILEFILTER

Consider that filters have to decide on file or directory. Perhaps
you are ignoring that part and getting everything turfed on that
account alone.

Consider that filters work with unqualified filenames, including the
dot.extension.

With my own filters, since you have source, it is pretty trivial to
add some debug code to figure out why files are being excluded. It
would become pretty obvious running the code in Eclipse tracing
through a few files what the problem is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top