springboot jar resource file
不能直接获取文件资源路径,但是可以通过流的方式读取资源
ClassPathResource resource = new ClassPathResource("static"+File.separator+"test.txt");
try (InputStream in = resource.getInputStream()){
//下载文件
return IOUtils.toString(in, StandardCharsets.UTF_8);
} catch (IOException.
原创
2020-12-01 14:10:20 ·
102 阅读 ·
0 评论