1 package com.ca.commons.cbutil; 2 3 import java.io.File ; 4 import java.io.FileFilter ; 5 6 10 11 public class CBFileFilter extends javax.swing.filechooser.FileFilter 12 implements FileFilter 13 { 14 protected String [] extensions; String description; 16 17 public CBFileFilter(String [] exts) 18 { 19 this(exts, "no description given"); 20 } 21 22 public CBFileFilter(String [] exts, String desc) 23 { 24 extensions = new String [exts.length]; 25 for (int i = 0; i < exts.length; i++) 26 { 27 extensions[i] = exts[i].toLowerCase(); 28 } 29 30 description = desc; 31 } 32 33 public boolean accept(File f) 34 { 35 if (f.isDirectory()) return true; 36 37 for (int i = 0; i < extensions.length; i++) 38 if (f.getName().toLowerCase().endsWith(extensions[i])) 39 return true; 40 41 return false; 42 } 43 44 public String getDescription() 45 { 46 return description; 47 } 48 49 } | Popular Tags |