import java.io.File;
public class DirSize {
public static void main(String[] args) {
File dir = new File("/home/huanyu/Desktop");
String[] files = dir.list();
if (files == null){
System.out.println("目录为空!!!");
}else {
for (int i=0; i<files.length; i++){
System.out.println(files[i]);
}
}
}
}
![img_f8b14ed1f2d04ce449e81e0b196031f5.png](https://yqfile.alicdn.com/img_f8b14ed1f2d04ce449e81e0b196031f5.png?x-oss-process=image/resize,w_1400/format,webp)