import java.io.File;

public class TestFile {
public static void main(String[] args) {
File file = new File("D:/A");
tree(file,0);
}
private static void tree(File f,int level) {
String tabSpace = "";
for(int i=0; i<level;i++) {
tabSpace+=" ";
}
File[] childs = f.listFiles();
for(int i=0; i<childs.length; i++) {
System.out.println(tabSpace + childs[i].getName());
if(childs[i].isDirectory()) {
tree(childs[i],level+1);
}
}
}
}

posted on 2015-07-23 08:08  太阳星辰  阅读(276)  评论(0编辑  收藏  举报