Directory Search using FilenameFilter

I have a directory that has over 100,000 files in the following format:

Invoice-100010001-16072007.xls

Invoice-100010001-16072007.pdf

I want to be able to find all files with a certain name (ie Invoice-100010001).

Is it possible to use a FilenameFilter to implement this?

[302 byte] By [dondragon2a] at [2007-11-27 10:43:34]
# 1

> Is it possible to use a FilenameFilter to implement

> this?

Yes! What part are you having trouble with?

sabre150a at 2007-7-28 20:01:10 > top of Java-index,Core,Core APIs...
# 2

I was just concern about the timing/perfomance. In the list method, is it a loop through all the files in the directory? Wouldn't this be a problem if I have over 10000 files?

dondragon2a at 2007-7-28 20:01:10 > top of Java-index,Core,Core APIs...
# 3

> I was just concern about the timing/perfomance. In

> the list method, is it a loop through all the files

> in the directory? Wouldn't this be a problem if I

> have over 10000 files?

Probably since Java loads all the files/directories index items and then filters them.

sabre150a at 2007-7-28 20:01:10 > top of Java-index,Core,Core APIs...
# 4

is there an alternative to the filter or any optimization that can be done?

dondragon2a at 2007-7-28 20:01:10 > top of Java-index,Core,Core APIs...
# 5

> is there an alternative to the filter or any

> optimization that can be done?

Not that I am aware of through pure Java. You may be able to do something with JNI or even with Runtime.exec().

sabre150a at 2007-7-28 20:01:10 > top of Java-index,Core,Core APIs...