⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wildcardfilefilter.java

📁 Jodd是一个开源的公用Java基础类库
💻 JAVA
字号:
package jodd.file.filters;

import java.io.File;
import java.io.FileFilter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import jodd.util.StringFlags;
import jodd.util.StringUtil;

/**
 * FileFilter that matches files against wildcard pattern (* and ?).
 *
 * For more details check the <code>FileFilterAbs</code> documentation.
 * For wildcard matching check the <code>StringUtil</code> documentation.
 *
 * @see jodd.file.filters.FileFilterAbs
 * @see jodd.util.StringUtil
 */
public class WildcardFileFilter extends FileFilterAbs {

	// ---------------------------------------------------------------- construction

	/**
	 * Regular Expression file filter.
	 *
	 * @param pattern regexp pattern
	 * @param opt     option string
	 */
	public WildcardFileFilter(String pattern, String opt) {
		super(pattern, opt);
	}

	/**
	 * Regular Expression file filter with default behaviour.
	 *
	 * @param pattern pattern
	 */
	public WildcardFileFilter(String pattern) {
		super(pattern);
	}

	/**
	 * Regular Expression file filter with no behaviour and that may be
	 * configured later.
	 */
	public WildcardFileFilter() {
		super();
	}

	// ---------------------------------------------------------------- FileFilterAbs.match()

	/**
	 * Wildcard matching.
	 *
	 * @param file   File to match.
	 *
	 * @return <code>true</code> if file name matches regular expression pattern,
	 *         <code>false</code> otherwise.
	 */
	public boolean match(File file) {
		return StringUtil.match(getFileName(file), pattern);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -