1 22 package org.jboss.util.file; 23 24 import java.io.File ; 25 import java.io.FilenameFilter ; 26 27 33 public class FilenamePrefixFilter 34 implements FilenameFilter 35 { 36 37 protected final String prefix; 38 39 40 protected final boolean ignoreCase; 41 42 48 public FilenamePrefixFilter(final String prefix, 49 final boolean ignoreCase) 50 { 51 this.ignoreCase = ignoreCase; 52 this.prefix = (ignoreCase ? prefix.toLowerCase() : prefix); 53 } 54 55 60 public FilenamePrefixFilter(final String prefix) { 61 this(prefix, false); 62 } 63 64 71 public boolean accept(final File dir, final String name) { 72 if (ignoreCase) { 73 return name.toLowerCase().startsWith(prefix); 74 } 75 else { 76 return name.startsWith(prefix); 77 } 78 } 79 } 80 | Popular Tags |