当前位置:   article > 正文

spring boot 打包jar后,resource下的模板文件读出为空的问题解决办法_jar包下载xlsx内容空白

jar包下载xlsx内容空白
此办法已验证可用,其他方法都不行。

ClassPathResource classPathResource = new ClassPathResource("/template/resultTemple.xlsx");
InputStream inputStream = classPathResource.getInputStream();
//生成目标文件
File somethingFile = File.createTempFile("Topic_Template", ".xlsx");
try {
    FileUtils.copyInputStreamToFile(inputStream, somethingFile);
} finally {
    IOUtils.closeQuietly(inputStream);
}
InputStream in = new FileInputStream(somethingFile);
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/815965
推荐阅读
相关标签
  

闽ICP备14008679号