0,0 → 1,48 |
package ak.resizeapplet; |
|
import java.util.Set; |
import java.util.HashSet; |
import java.io.File; |
import javax.swing.filechooser.FileFilter; |
|
public class ExtFileFilter extends FileFilter |
{ |
private String description; |
private Set extensions = new HashSet(); |
|
public ExtFileFilter(String description) |
{ |
this.description = description; |
} |
|
public boolean accept(File f) |
{ |
if(f == null) return false; |
if(f.isHidden()) return false; |
if(f.isDirectory()) return true; |
|
String name = f.getName(); |
int pos = name.lastIndexOf('.'); |
String ext; |
|
if(pos <= 0 || pos >= name.length()-1) { |
ext = ""; |
} |
else { |
ext = name.substring(pos+1).toUpperCase(); |
} |
|
return extensions.contains(ext); |
} |
|
public void addExtension(String ext) |
{ |
extensions.add(ext.toUpperCase()); |
} |
|
public String getDescription() |
{ |
return description; |
} |
} |
|