myfilefilter.java
来自「用来管理在校学生的出勤.作息等的管理系统」· Java 代码 · 共 40 行
JAVA
40 行
/*
* @author 黎龙飞 , 创建日期 2008-5-3
*
* Blog : http://lilongfei1030.blog.163.com
*/
package stu.view;
import java.io.File;
import javax.swing.filechooser.FileFilter;
public class MyFileFilter extends FileFilter {
String ext;
public MyFileFilter(String ext) {
this.ext = ext;
}
public boolean accept(File file) {
if (file.isDirectory()) {
return true;
}
String fileName = file.getName();
int index = fileName.lastIndexOf('.');
if (index > 0 && index < fileName.length() - 1) {
String extension = fileName.substring(index + 1).toLowerCase();
if (extension.equals(ext))
return true;
}
return false;
}
public String getDescription() {
return "File(*." + ext + ")";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?