package stimulusdelayreward;
import java.io.FilenameFilter;
import java.io.File;
/** Accept files that have one of the provided extension.
*
* @author Francois Rivest
* @version 1.0
*/publicclassExtensionFilterimplementsFilenameFilter {
/** List of allowed extensions. */private String[] m_ExtensionsList;
/** Construct a filter that accept any file ending with one of the provided
* extension. The . should not be in the string.
* @param extensionsList List of extensions allowed.
*/publicExtensionFilter(String[] extensionsList) {
m_ExtensionsList = newString[extensionsList.length];
//preprocess by adding '.' and lower casing.for (int i=0; i<extensionsList.length; i++)
{
m_ExtensionsList[i] = "." + extensionsList[i].toLowerCase();
}
}
publicbooleanaccept(File dir, String name) {
//preprocessStringlname= name.toLowerCase();
//checkfor (int i=0; i<m_ExtensionsList.length; i++) {
if (lname.endsWith(m_ExtensionsList[i])) {
returntrue;
}
}
returnfalse;
}
}