jodd.io.filter.RegExpFileFilter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jodd-core Show documentation
Show all versions of jodd-core Show documentation
Jodd Core tools and utilities, including type converters, JDateTime, cache etc.
// Copyright (c) 2003-2014, Jodd Team (jodd.org). All Rights Reserved.
package jodd.io.filter;
import java.io.File;
import java.util.regex.Pattern;
/**
* FileFilter that matches files with use of Regular Expression.
*
* Some tips for regular expressions:
*
* - .* : matches any number of character
* - .? : matches zero or one character
*
*/
public class RegExpFileFilter extends FileFilterBase {
private final Pattern regexpPattern;
public RegExpFileFilter(String pattern) {
regexpPattern = Pattern.compile(pattern);
}
@Override
public boolean accept(File dir, String name) {
return regexpPattern.matcher(name).matches();
}
}