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