获取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"));
标签:src,resource,路径,getPath,classes,File,new,fileNamePath 来源: https://www.cnblogs.com/fightmonster/p/15863320.html