public class Demo{
static int level;
public static void main(String[] args) throws IOException {
//利用递归遍历目录下的所有文件
File file = new File("F:\\study\\PHPTutorial\\WWW\\template\\default_wap");
parseFile(file);
}
public static void parseFile(File file){
if (file == null || !file.exists()){
return;
}
level ++;
File[] files = file.listFiles();
for (File f : files){
for (int i = 0; i < level; i++) {
System.out.print("\t");
}
System.out.println(f.getName());
if (f.isDirectory()){
parseFile(f);
}
}
level--;
}
}
递归 遍历目录下的所有文件
最新推荐文章于 2021-01-15 09:31:30 发布