标签:direct str level out name -- sdi for director
文件
public static void printFile(File f,int level){
for(int i=0;i<level;++i){
System.out.print("-");
}
System.out.println(f.getName());
if(f.isDirectory()){
File[] files=f.listFiles();
for(File file:files){
printFile(file,level+1);
}
}
}
public static void main(String[] args) {
File f=new File("e:/aa");
printFile(f,0);
}
打印结果 :
aa
-a.txt
-bb
--b.txt
--cc
---c.txt
---dd
----d.txt
标签:direct str level out name -- sdi for director
原文地址:http://www.cnblogs.com/jrts/p/6106744.html