java.io

Interface FilenameFilter

Known Subinterfaces:
IOFileFilter
Known Implementing Classes:
AbstractFileFilter, AgeFileFilter, AndFileFilter, AwkFilenameFilter, CanReadFileFilter, CanWriteFileFilter, DelegateFileFilter, DirectoryFileFilter, EmptyFileFilter, FalseFileFilter, FileFileFilter, GlobFilenameFilter, HiddenFileFilter, IndexFileNameFilter, JarFilenameFilter, NameFileFilter, NotFileFilter, OrFileFilter, Perl5FilenameFilter, PrefixFileFilter, RegexFileFilter, RegexFilenameFilter, SizeFileFilter, SuffixFileFilter, TrueFileFilter, WildcardFileFilter, WildcardFilter

public interface FilenameFilter

Instances of classes that implement this interface are used to filter filenames. These instances are used to filter directory listings in the list method of class File, and by the Abstract Window Toolkit's file dialog component.
Since:
JDK1.0
See Also:
FileDialog.setFilenameFilter(FilenameFilter), File, File.list(FilenameFilter)

Method Summary

boolean
accept(File dir, String name)
Tests if a specified file should be included in a file list.

Method Details

accept

public boolean accept(File dir,
                      String name)
Tests if a specified file should be included in a file list.
Parameters:
dir - the directory in which the file was found.
name - the name of the file.
Returns:
true if and only if the name should be included in the file list; false otherwise.
Usages and Demos :

View More Examples of accept(File dir,String name)
   1: import java.io.File;
   2: import java.io.FilenameFilter;
   3: 
   4:         ...
   5: public class InvertedFileFilter
   6:     implements FilenameFilter
   7: {
   8:         ...
   9:     private final FilenameFilter m_originalFilter;
  10: 
  11:         ...
  12:     {
  13:         return !m_originalFilter.accept( file, name );

View Full Code Here
   1: import java.io.File;
   2: import java.io.FilenameFilter;
   3: 
   4:         ...
   5: public class AndFileFilter
   6:     implements FilenameFilter
   7: {
   8:         ...
   9:     private final FilenameFilter m_filter1;
  10:     private final FilenameFilter m_filter2;
  11:         ...
  12:     {
  13:         return m_filter1.accept( file, name ) && m_filter2.accept( file, name );

View Full Code Here
   1: 
   2:     protected FilenameFilter filter;
   3: 
   4:         ...
   5:     static public boolean contains(File f, FilenameFilter filter)
   6:     {
   7:         ...
   8:     
   9:     static public boolean matches(ZipEntry ety, FilenameFilter filter)
  10:     {
  11:         ...
  12:         if (filter!=null)
  13:             return filter.accept(null,entryName);

View Full Code Here
   1: 
   2:     protected FilenameFilter filter;
   3: 
   4:         ...
   5:     static public boolean contains(File f, FilenameFilter filter)
   6:     {
   7:         ...
   8:     
   9:     static public boolean matches(ZipEntry ety, FilenameFilter filter)
  10:     {
  11:         ...
  12:         if (filter!=null)
  13:             return filter.accept(null,entryName);

View Full Code Here
   1: 
   2:     protected FilenameFilter filter;
   3: 
   4:         ...
   5:     static public boolean contains(File f, FilenameFilter filter)
   6:     {
   7:         ...
   8: 
   9:     static public boolean matches(TarEntry ety, FilenameFilter filter)
  10:     {
  11:         ...
  12:         if (filter!=null)
  13:             return filter.accept(null,entryName);

View Full Code Here