public static void main(String[] args) {
t10();
}
//遍历指定目录下的所有目录
public static void t10(){
File dir = new File("F:\\IOTest_zx\\one");
File[] fs = dir.listFiles();
FileFilter filter = new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory();
}
};
fs = dir.listFiles(filter);
System.out.println(fs.length);
if (fs.length == 0){
System.out.println("目录不存在或它不是一个目录");
}else {
for (int i = 0; i < fs.length; i++) {
File fileName = fs[i];
System.out.println(fileName.toString());
}
}
}
来源:CSDN
作者:Dr_W
链接:https://blog.csdn.net/qq_42363032/article/details/103659731