首页 > 技术文章 > 递归过去文件夹下所有文件目录

ybniu 2020-12-31 17:08 原文


递归过去文件夹下所有文件目录
private void getFileList(List<File> fileList, String path) {
File dirFile = new File(path);
File[] files = dirFile.listFiles();
Assert.notNull(files, "获取文件为空");

for (File file : files) {
if (file.isFile()) {
fileList.add(file.getAbsoluteFile());
} else {
getFileList(fileList, file.getAbsolutePath());
}
}
}

推荐阅读