Chinaunix首页 | 论坛 | 博客
  • 博客访问: 55093
  • 博文数量: 16
  • 博客积分: 408
  • 博客等级: 一等列兵
  • 技术积分: 140
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-24 09:07
文章分类
文章存档

2012年(16)

我的朋友

分类: Java

2012-02-29 21:31:03

private FileFilter getFileFilter(final String type){
return new FileFilter(){

@Override
public boolean accept(File pathname) {
boolean ret = false;
final String name =  pathname.getName();
// File thisfile = new File(file.getPath() + "/" + name);
if (type.equals(Util.PDF_TYPE)) {
ret = name.toUpperCase().endsWith(Util.PDF_DATA_TYPE)
|| pathname.isDirectory();
} else if (type.equals(Util.DOC_TYPE)) {
ret = name.toUpperCase().endsWith(Util.WORD_DATA_TYPE)
|| pathname.isDirectory();
} else if (type.equals(Util.PIC_TYPE)) {
ret = name.toUpperCase().endsWith(
Util.PNG_PICTURE_DATA_TYPE)
|| name.toUpperCase().endsWith(
Util.JPG_PICTURE_DATA_TYPE)
|| name.toUpperCase().endsWith(
Util.BMP_PICTURE_DATA_TYPE)
|| pathname.isDirectory();
}

// boolean ret = name.endsWith(_extension) ||
// file.isDirectory();
return ret;
}
};
}
阅读(1207) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~