package org.weebing.ai.util;
import java.io.File;
public class Directory {
public static File[] getCurFilesList(String filePath) {
File path = new File(filePath);
File[] listFiles = path.listFiles(new java.io.FileFilter() {
@Override
public boolean accept(File pathname) {
if (pathname.isFile())
return true;
else
return false;
}
});
return listFiles;
}
public static void main(String[] args) {
String filePath = "E:\\最近工作\\毕设";
File[] fileList = Directory.getCurFilesList(filePath);
for (File file : fileList) {
System.out.println(file.getName());
}
}
}
这里用到了匿名函数!