Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6540610
Votes 0
Synopsis File{name}?Filter should have basic implementations
Category java:classes_io
Reported Against
Release Fixed
State 11-Closed, duplicate of 4313887, request for enhancement
Priority: 5-Very Low
Related Bugs
Submit Date 29-MAR-2007
Description
A DESCRIPTION OF THE REQUEST :
Java should provide some basic implementations of the FileFilter and FilenameFilter interfaces: at least a 'filename extension' based and a 'regular expression' based.

Also, a 'bridge/adapter' class should be provided to easily allow FilenameFilter implementations, to easily implements FileFilter as well.

Also

JUSTIFICATION :
99% of the times a FileFilter/FilenameFilter is used, it is manually implemented each time around a set of extensions (like catching all .cfg .txt .whatever files) or around a regular expression.

Given that it's very very easy to provide a couple of implementations for these two cases, and given that a the strength of a language relies mostly on the strength and completeness of its libraries, I really think this is a 'hole' that can be easily filled up, and make customers (=developers) happy, instead of force them to write a custom implementation each time they even want to filter files by extension in a save dialog box.

I have myself coded at least for 5 different projects I've been working on, the same similar util classes ExtensionFileFilter and RegexFileFilter, they are LESS than 10 lines of code, and they allow me to avoid spamming sources with anonymous class each time I want to use a FileFilter.

I seriously think these should be in the java libraries :)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Java should give basic implementations (at least extension and regex) of FileFilter and FilenameFilter implementation, and also provide a way to easily 'wrap' FilenameFilter implementation as FileFilters.
ACTUAL -
_NO_ implementation of these interfaces is provided. Each time a developer want to do such a simple thing like filtering files by extension or by a regular expression, he has to provide an implementation for this interface.

CUSTOMER SUBMITTED WORKAROUND :
If needed, I can easily provide a working version of ExtensionFileFilter and RegexFileFilter, alongs with a FilenameFileFilter which can acts both as a base class or a wrapper class, to make a FilenameFilter implements FileFilter interface.
Posted Date : 2007-03-29 22:56:04.0
Work Around
N/A
Evaluation
This feature has been addressed by the new file system API defined by JSR-203. In particular, it supports built-in filtering using globs or regular expressions and a utility method to obtain a filter that filters by MIME type.
Posted Date : 2009-02-16 13:32:27.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang