public boolean accept(File directory, String fileName) {
boolean fileOK = true;
if (name != null) {
fileOK &= fileName.startsWith(name);
}
if (pattern != null) {
fileOK &= Pattern.matches(regex, fileName);
}
if (extension != null) {
fileOK &= fileName.endsWith('.' + extension);
}
return fileOK;
}