标签:
1 import java.io.*; 2 3 public class FileList { 4 public static void main (String[] args){ 5 File f = new File("d:/A"); 6 System.out.println(f.getName()); 7 tree(f,1); 8 } 9 10 private static void tree(File f,int level) { 11 File[] childs= f.listFiles(); 12 for(int i = 0; i < childs.length; i++){ 13 for(int j = 0; j < level; j++){ 14 System.out.print(" "); 15 } 16 System.out.println(childs[i].getName()); 17 if(childs[i].isDirectory()){ 18 tree(childs[i],level + 1); 19 } 20 } 21 22 } 23 }
标签:
原文地址:http://www.cnblogs.com/roger-h/p/4464050.html