1 5 30 package com.teamkonzept.field; 31 32 import java.io.*; 33 import com.teamkonzept.lib.*; 34 35 public class TKUploadFilenameFilter implements FilenameFilter { 36 37 TKVector extensionVector; 38 39 public TKUploadFilenameFilter( TKVector extensionVector) { 40 this.extensionVector = extensionVector; 41 } 42 43 44 48 public boolean accept(File dir, String name) 49 { 50 51 54 if (!new File( dir, name ).isDirectory()) { 56 String sep = "."; 57 58 for(int i=0; i < extensionVector.size(); i++) { 60 String extension = (String ) extensionVector.elementAt(i); 61 int sepIdx = name.lastIndexOf(sep); 62 String fileExt = name.substring( sepIdx+1, name.length() ); 63 if( fileExt.equals(extension) ) 64 return true; 65 } 66 return false; 67 } 68 else 69 return false; 70 71 } 72 73 74 75 } 79 | Popular Tags |