1 26 27 package org.objectweb.jonas.server; 28 29 import java.util.StringTokenizer ; 31 import java.io.File ; 32 import java.io.FileFilter ; 33 34 39 public class JFileFilter implements FileFilter { 40 41 44 private String [] extensions = null; 45 46 51 public JFileFilter(String filter) { 52 StringTokenizer st = new StringTokenizer (filter, ","); 53 int tokenCount = st.countTokens(); 54 extensions = new String [tokenCount]; 55 for (int i = 0; i < tokenCount; i++) { 56 extensions[i] = st.nextToken(); 57 } 58 } 59 60 66 public boolean accept(File pathname) { 67 if (pathname.isDirectory()) { 68 return true; 69 } else { 70 for (int i = 0; i < extensions.length; i++) { 71 if (extensions[i].equals(".*")) { 72 return true; 73 } else { 74 if (pathname.getName().endsWith(extensions[i])) { 75 return true; 76 } 77 } 78 } 79 return false; 80 } 81 } 82 } | Popular Tags |