package com.x.filter;
import java.io.File;
import java.io.FilenameFilter;
/**
* ImageFilter: only gif,jpg,png can be accept
*
* @author yinger
* @time 2011-5-1 下午03:40:19
* @mail melody.crazycoding@gmail.com
*/
public class PicFilter implements FilenameFilter {
@Override
public boolean accept(File arg0, String fname) {
// TODO Auto-generated method stub
return (isGif(fname) || isJpg(fname) || isPng(fname));
}
private boolean isGif(String file) {
if (file.toLowerCase().endsWith(".gif")) {
return true;
} else {
return false;
}
}
private boolean isJpg(String file) {
if (file.toLowerCase().endsWith(".jpg")) {
return true;
} else {
return false;
}
}
private boolean isPng(String file) {
if (file.toLowerCase().endsWith(".png")) {
return true;
} else {
return false;
}
}
}
posted on 2011-05-25 11:59
Ying-er 阅读(441)
评论(0) 编辑 收藏