import java.io.File;
import java.io.FileFilter;
public class PrintDir {
public static void main(String[] args) {
File dir = new File("/");
File[] files = null;
FileFilter fileFilter = new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory();
}
};
files=dir.listFiles(fileFilter);
System.out.println(files.length);
if (files.length ==0){
System.out.println("目录为空!!");
}else {
for (int i=0; i<files.length; i++){
File filename = files[i];
System.out.println(filename.toString());
}
}
}
}