读取目录下的所有文件
采用递归的方式,逐层读取目录下的文件
public void getFile(String path, List<String> fileList) {
File file = new File(path);
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files != null) {
for (File subFile : files) {
getFile(subFile.getPath(), fileList);
}
}
} else {
fileList.add(file.getAbsolutePath());
}
}

浙公网安备 33010602011771号