SpringBoot获取指定Resource下的文件

时间:2020-11-19 00:23:58   收藏:0   阅读:199

加入依赖

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.8.0</version>
        </dependency>

具体代码

import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;


@Value("classpath:test.json")
Resource resource;

List<String> stringList = IOUtils.readLines(resource.getInputStream());
        System.out.println(stringList);

技术分享图片

 

原文:https://www.cnblogs.com/chenyanbin/p/14002588.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!