sPathResource classPathResource = new ClassPathResource("excleTemplate/test.xlsx");
InputStream inputStream =classPathResource.getInputStream();


第二种

File file = ResourceUtils.getFile("classpath:excleTemplate/test.xlsx");
InputStream inputStream = new FileInputStream(file);

 

------------------------------

读取resource/static/a.html文件的内容

ClassPathResource classPathResource=new ClassPathResource("static/a.html");
byte[] bytes= Files.readAllBytes(Paths.get(classPathResource.getAbsolutePath()));
String html=new String(bytes);

 

相关文章:

  • 2022-12-23
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2021-04-07
  • 2022-02-08
猜你喜欢
  • 2022-03-01
  • 2022-12-23
相关资源
相似解决方案