首页 > 编程语言 > 详细

Spring Boot 读取 resource 下文件

时间:2018-12-14 18:37:11      阅读:252      评论:0      收藏:0      [点我收藏+]

支持linux下读取

import org.springframework.core.io.ClassPathResource;
 
public InputStream getCertStream() {
          try {
            ClassPathResource classPathResource = new ClassPathResource("config/apiclient_cert.p12");
            //获取文件流
            InputStream certStream = classPathResource.getInputStream();
            this.certData = IOUtils.toByteArray(certStream);
            certStream.read(this.certData);
            certStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
   }

 

Spring Boot 读取 resource 下文件

原文:https://www.cnblogs.com/fengqiaoyebo/p/10120790.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!