获取src资源文件编译后的路径(即classes路径)

//获取src资源文件编译后的路径(即classes路径)

URL resource = this.getClass().getClassLoader().getResource("template/paramTemplate.xlsx");
if (resource == null) {
    throw new CustomException(600, "模板文件不存在");
}
String fileNamePath = resource.getPath();
ExcelUtil.downloadFile(response, new File(fileNamePath));

//处理路径中文乱码

File directory = new File(java.net.URLDecoder.decode(url.getPath(), "utf-8"));
上一篇:maven无法读取xml


下一篇:「洛谷3870」「TJOI2009」开关【线段树】