public class $ { public static void main(String[] args) { String path = "D:\\111"; test(path); }
private static void test(String path) { File f = new File(path); File[] fs = f.listFiles(); if (fs == null) { return; } for (File file : fs) { if (file.isFile()) { System.out.println(file.getPath()); } else { test(file.getPath()); } } } }
原文:https://www.cnblogs.com/zhangxiong-tianxiadiyi/p/10853382.html