Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 16 package org.apache.commons.io.filefilter; 17 18 import java.io.File ; 19 import java.util.List ; 20 21 45 public class SuffixFileFilter extends AbstractFileFilter { 46 47 48 private String [] suffixes; 49 50 56 public SuffixFileFilter(String suffix) { 57 if (suffix == null) { 58 throw new IllegalArgumentException ("The suffix must not be null"); 59 } 60 this.suffixes = new String [] {suffix}; 61 } 62 63 72 public SuffixFileFilter(String [] suffixes) { 73 if (suffixes == null) { 74 throw new IllegalArgumentException ("The array of suffixes must not be null"); 75 } 76 this.suffixes = suffixes; 77 } 78 79 86 public SuffixFileFilter(List suffixes) { 87 if (suffixes == null) { 88 throw new IllegalArgumentException ("The list of suffixes must not be null"); 89 } 90 this.suffixes = (String []) suffixes.toArray(new String [suffixes.size()]); 91 } 92 93 99 public boolean accept(File file) { 100 String name = file.getName(); 101 for (int i = 0; i < this.suffixes.length; i++) { 102 if (name.endsWith(this.suffixes[i])) { 103 return true; 104 } 105 } 106 return false; 107 } 108 109 116 public boolean accept(File file, String name) { 117 for (int i = 0; i < this.suffixes.length; i++) { 118 if (name.endsWith(this.suffixes[i])) { 119 return true; 120 } 121 } 122 return false; 123 } 124 125 } 126
| Popular Tags
|