View Javadoc
1 /* 2 * (C) 2002 David Carr david@carr.name 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 package net.sourceforge.mflow.util; 20 21 import java.io.File; 22 import java.io.FilenameFilter; 23 24 /*** 25 * @author carrd 26 */ 27 public class FilenameExtensionFilter implements FilenameFilter { 28 private String[] extensions; 29 30 FilenameExtensionFilter(String[] extensions) { 31 this.extensions = extensions; 32 } 33 34 /*** 35 * @param extension the filename extension to include in the filter 36 */ 37 public FilenameExtensionFilter(String extension) { 38 this.extensions = new String[] { extension }; 39 } 40 41 /*** 42 * Includes all files that end in the specified extension, case insensitively 43 * 44 * @param dir the parent directory 45 * @param name the filename to check 46 * @return whether it should be included 47 */ 48 public boolean accept(File dir, String name) { 49 for (int i = 0; i < this.extensions.length; i++) { 50 String extension = this.extensions[i]; 51 if (name.toLowerCase().endsWith(extension.toLowerCase())) { 52 return true; 53 } 54 } 55 return false; 56 } 57 }

This page was automatically generated by Maven