- public static void main(String[] args) {
- //文件名称过滤器
- File dir = new File("D:\\");
- File[] arr = dir.listFiles(new FilenameFilter() {
-
- @Override
- public boolean accept(File dir, String name) {
- File file = new File(dir, name);
- if (!file.isFile()) {
- return false;
- }
- boolean b = 200 > file.length()? true : false;
- return b;
- }
- });
-
- for (File file : arr) {
- System.out.println(file);
- }
- }
复制代码
在比较器里比较 |