private static void tree(File f,int level){
String preStr = "";
for (int i = 0; i < level; i++) {
preStr+=" ";
}
File [] childs = f.listFiles();
for (int i = 0; i < childs.length; i++) {
System.out.println(preStr+childs[i].getName());
if(childs[i].isDirectory()){
tree(childs[i],++level);
}
}
}
时间: 2024-10-14 03:20:49