FileDocCategorySizeDatePackage
ExtensionFileFilter.javaAPI DocApache James 2.3.12589Fri Jan 12 12:56:34 GMT 2007org.apache.james.util.io

ExtensionFileFilter

public class ExtensionFileFilter extends Object implements FilenameFilter
This filters files based on the extension (what the filename ends with). This is used in retrieving all the files of a particular type.

Eg., to retrieve and print all *.java files in the current directory:

File dir = new File(".");
String[] files = dir.list( new ExtensionFileFilter( new String[]{"java"} ) );
for (int i=0; i<files.length; i++)
{
System.out.println(files[i]);
}
author
Federico Barbieri
author
Serge Knystautas
author
Peter Donald
version
CVS $Revision: 494012 $ $Date: 2007-01-08 11:23:58 +0100 (Mo, 08 Jan 2007) $
since
4.0

Fields Summary
private String[]
m_extensions
Constructors Summary
public ExtensionFileFilter(String[] extensions)

        m_extensions = extensions;
    
public ExtensionFileFilter(String extension)

        m_extensions = new String[]{extension};
    
Methods Summary
public booleanaccept(java.io.File file, java.lang.String name)

        for( int i = 0; i < m_extensions.length; i++ )
        {
            if( name.endsWith( m_extensions[ i ] ) )
            {
                return true;
            }
        }
        return false;