sdsu.io
Class FilePrefixFilter
java.lang.Object
|
+--sdsu.io.FilePrefixFilter
- public class FilePrefixFilter
- extends java.lang.Object
- implements java.io.FilenameFilter
FilePrefixFilter can be used by java.io.File and java.awt.FileDialog
to select files with a given file prefix. A file prefix is the
text before a "." in the file name. So foo.bar.txt has the
prefix foo, and foo.bar. Given either prefix
the filter will accept the file foo.bar.txt. That is when
The comparison of the file extension is not case sensitive. So lost
is considered the same as LOST
A sample use:
File currentDirectory = new File( "." );
String[] listing = currentDirectory.list( new FilePrefixFilter("lost"));
gives all the file starting with "lost" 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 |
FilePrefixFilter
public FilePrefixFilter(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.
- Specified by:
- accept in interface java.io.FilenameFilter