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.
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.
- duplicates
-
JDK-4313887 New I/O: Improved filesystem interface
- Resolved