import java.io.*;
public class FileList {
public static void main(String[] args) {
File f = new File("G:\\笔试 面试题");
System.out.println(f.getName());
tree(f, 1);
}
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 + 1);
}
}
}
}
文件列表的问题
最新推荐文章于 2023-09-16 09:27:38 发布