标签:direct @param 文件 dal fileutils child row path add
/**
* 返回传入路径下的所有.conf文件
* @param filePath
* @return
* @throws FileNotFoundException
*/
public static ArrayList<File> getFilesEndWithConf(String filePath) throws FileNotFoundException {
ArrayList<File> files = new ArrayList<>();
File file = new File(filePath);
if (file.isDirectory()) {
File[] file_childrens = file.listFiles((dir,name)-> dir.isDirectory()||name.endsWith(".conf"));
for (File file_children:file_childrens){
if (file_children.isDirectory()){
files.addAll(FileUtils.getFilesEndWithConf(file_children.getPath()));
}else{
files.add(file_children);
}
}
return files;
} else if (file.isFile()){
files.add(file);
return files;
} else {
throw new FileNotFoundException("根据指定路径未找到文件:"+filePath);
}
}
标签:direct @param 文件 dal fileutils child row path add
原文地址:https://www.cnblogs.com/BigWrite/p/13074249.html