15. 获取类路径下文件对应的输入流(inputStream)方式

Posted on 2019-12-25 16:15  zkx4213  阅读(3375)  评论(0)    收藏  举报

//获取 inputStream 方式一
Resource resource = new ClassPathResource("excel/template/test.xlsx");
InputStream inputStream = resource.getInputStream();


//获取 inputStream 方式二
InputStream inputStream = TestController.class.getResourceAsStream("/excel/template/test.xlsx");

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3