1 17 18 19 20 package org.apache.lenya.cms.ant; 21 22 import java.io.File ; 23 import java.io.FilenameFilter ; 24 import java.util.Arrays ; 25 import java.util.StringTokenizer ; 26 27 public class JavaFilenameFilter implements FilenameFilter { 28 29 protected static final String [] SUFFIXES = { "java", "properties", "xml", "xsl", "jdo", "dtd" }; 30 31 35 public boolean accept(File dir, String name) { 36 boolean accept = true; 37 if (new File (dir, name).isFile()) { 38 String suffix = getExtension(name); 39 if (!Arrays.asList(SUFFIXES).contains(suffix)) { 40 accept = false; 41 } 42 } 43 return accept; 44 } 45 46 52 static public String getExtension(String filename) { 53 StringTokenizer st = new StringTokenizer (filename, "."); 54 st.nextToken(); 55 56 String extension = ""; 57 58 while (st.hasMoreTokens()) { 59 extension = st.nextToken(); 60 } 61 62 return extension; 63 } 64 } 65 | Popular Tags |