public static List getFiles(String path) {
List files = new ArrayList();
File file = new File(path);
File[] tempList = file.listFiles();
assert tempList != null;
for (File value : tempList) {
if (value.isFile()) {
files.add(value.toString());
}
if (value.isDirectory()) {
List files1 = getFiles(value.getPath());
files.addAll(files1);
}
}
return files;
}
参考链接:https://www.cnblogs.com/shaosks/p/9625878.html



