File[] libs = libDir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
return !pathname.isDirectory() && pathname.getName().endsWith(".jar");
}
});
This example is a very simple one but since this is a method instead of a pattern like *.jar there are no limitations how the filtering is done. Regular expressions, web services, databases, relations of file names, ... I do like that approach since even it is powerful it's still simple and easy to use. If all API's were designed like this software development would be simpler and faster.
test driving of java applications
Mittwoch, 17. Juni 2009
java.io.FileFilter - a pragmatic and powerful way to select files
Today I discovered the FileFilter interface. A little bit late maybe - but better late than never!
Abonnieren
Kommentare zum Post (Atom)
Beitragende
Archives
-
▼
2009
(26)
-
►
Mai
(11)
- The future of the human race
- EasyMock as an easy to use alternative to jMock
- Sniffing keystrokes from wireless keyboards
- JPA and default values
- Expose for Vista
- Germany - a country full of terrorists
- jQuery Autocomplete Plugin
- sunshine live webradio without the annoying advert...
- UTF-8 character encoding problems with ISO-8859-1 ...
- Hibernate Transactions and Connection Pooling
- How to install Eclipse Subversive SVN Plugin
-
►
Mai
(11)
0 Kommentare:
Kommentar veröffentlichen