输出目录下所有文件 素颜马尾好姑娘i 2022-11-16 10:50 195阅读 0赞 public class PathAll { private static void pathall(String path){ File file = new File(path); File[] fs =file.listFiles(); if (fs==null){ System.out.println("不存在"); return; } for (File f:fs) { if (f.isFile()){ System.out.println(f.getPath()); }else { pathall(f.getPath()); } } } public static void main(String[] args) { String dir ="F:\\Downloads\\笔记"; pathall(dir); } }
还没有评论,来说两句吧...