java递归所有目录
1 package io.test; 2 3 import java.io.File; 4 5 /** 6 *递归遍历所有的目录 7 */ 8 public class DirAll { 9 public static void main(String[] args) { 10 System.out.println("======"); 11 File f = new File("./"); 12 getAllDirectory(f); 13 } 14 public static void getAllDirectory(File f){ 15 File[] files = f.listFiles(); 16 if (files!=null){ 17 for (File file:files){ 18 if (file.isDirectory()){ 19 getAllDirectory(file); 20 }else{ 21 System.out.println(file.getAbsolutePath()); 22 } 23 } 24 } 25 } 26 }