pro.shuangxi.utils.RenderDataUtils Maven / Gradle / Ivy
package pro.shuangxi.utils;
import pro.shuangxi.pojo.RenderData;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* @author mengshx
* @description 文件相关工具类
* @date 2022-07-15 11:00
**/
public class RenderDataUtils {
public static List getRenderDataWithPerfix(File directory, String suffix,String perfix) {
List renderDataList = new ArrayList<>();
getPath(renderDataList, "", directory,suffix, perfix);
return renderDataList;
}
private static void getPath(List pathList, String path, File directory,String suffix,String perfix) {
for (File file : directory.listFiles()) {
if (file.isDirectory()) {
getPath(pathList,path+file.getName()+File.separator,file,suffix,perfix);
}else {
if (file.getName().contains(suffix)) {
pathList.add(new RenderData(path + file.getName(),path + perfix+file.getName().replace(suffix,"")));
}
}
}
}
}