Here you can find the source of getFilesByRegxFileName(String dir, final String regxName)
public static File[] getFilesByRegxFileName(String dir, final String regxName)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileFilter; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static File[] getFilesByRegxFileName(String dir, final String regxName) { if (dir == null) throw new NullPointerException("dir must not be null"); File dirc = new File(dir); if (!dirc.exists() || !dirc.isDirectory()) { throw new IllegalArgumentException("dir must be exists directory"); }// w ww .java2 s . com File[] files = dirc.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { Pattern pattern = Pattern.compile(regxName); Matcher matcher = pattern.matcher(pathname.getName()); if (pathname.isDirectory() || (!(matcher.find()))) { return false; } return true; } }); return files; } }