sdsu.io
Class FileExtensionFilter
java.lang.Object
|
+--sdsu.io.FileExtensionFilter
- public class FileExtensionFilter
- extends java.lang.Object
- implements java.io.FilenameFilter
FileExtensionFilter can be used by java.io.File and java.awt.FileDialog
to select files with a given file extension. A file extension is the
text after a "." in the file name. So foo.bar.txt has the
extension txt, it also has the extension .bar.txt. Given either extension
the filter will return the file foo.bar.txt.
The comparison of the file extension is not case sensitive. So .txt
is considered the same as .TXT
A sample use:
File currentDirectory = new File( "." );
String[] listing = currentDirectory.list( new FileExtensionFilter("html"));
gives all the file ending in .html in the current directory.
- Version:
- 1.0 11 November 1997
- Author:
- Roger Whitney
(whitney@cs.sdsu.edu)
Method Summary |
boolean |
accept(java.io.File directory,
java.lang.String fileName)
Called by File and FileDialog to select files. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
FileExtensionFilter
public FileExtensionFilter(java.lang.String extension)
- Parameters:
extension
- the file extension to be filtered for.
The strings .txt and txt will both filter for files ending in .txt
accept
public boolean accept(java.io.File directory,
java.lang.String fileName)
- Called by File and FileDialog to select files.
Returns true on file names that File and FileDialog should accept
- Specified by:
- accept in interface java.io.FilenameFilter