FileFilter


FileFilter java.io

Java 1.2

This interface, added in Java 1.2, defines an accept( ) method that filters a list of files. You can list the contents of a directory by calling the listFiles( ) method of the File object that represents the desired directory. If you want a filtered listing, such as a listing of files but not subdirectories or a listing of files whose names end in .class , you can pass a FileFilter object to listFiles( ) . For each entry in the directory, a File object is passed to the accept( ) method. If accept( ) returns true , that File is included in the return value of listFiles( ) . If accept( ) returns false, that entry is not included in the listing. Use FilenameFilter if compatibility with previous releases of Java is required or if you prefer to filter filenames (i.e., String objects) rather than File objects.

 public interface  FileFilter  {  // Public Instance Methods  boolean  accept  (File  pathname  );   } 

Passed To

File.listFiles( )



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net