1 17 18 19 20 package org.apache.lenya.util; 21 22 import java.io.File ; 23 import java.io.FilenameFilter ; 24 import java.util.regex.Pattern ; 25 26 29 public class RegexFilter implements FilenameFilter { 30 31 private Pattern pattern; 32 33 38 public RegexFilter(String pattern) 39 { 40 if (pattern != null) 41 { 42 this.pattern = Pattern.compile(pattern); 43 } 44 } 45 46 47 54 public boolean accept(File dir, String name) 55 { 56 if (!(new File (dir, name).isFile())) return false; 57 58 if (pattern != null && !(pattern.matcher(name).matches())) return false; 59 60 return true; 61 } 62 63 } 64 65 | Popular Tags |