- public void traverseFolder2(String path) {
-
- File file = new File(path);
- if (file.exists()) {
- File[] files = file.listFiles();
- if (files.length == 0) {
- System.out.println("文件夹是空的!");
- return;
- } else {
- for (File file2 : files) {
- if (file2.isDirectory()) {
- System.out.println("文件夹:" + file2.getAbsolutePath());
- traverseFolder2(file2.getAbsolutePath());
- } else {
- System.out.println("文件:" + file2.getAbsolutePath());
- }
- }
- }
- } else {
- System.out.println("文件不存在!");
- }
- }
posted @
2016-08-30 19:19
猴子1
阅读(
434)
评论()
编辑
收藏
举报