您当前的位置: 首页 > 

zmc@

暂无认证

  • 1浏览

    0关注

    142博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

读取resource根目录下的配置文件---标准

zmc@ 发布时间:2019-01-10 12:11:23 ,浏览量:1

//读取配置文件
//fileName="conf.json";
    public String getConf(String fileName) {
        String content="";
        try {
            //jsonFile = ResourceUtils.getFile("classpath:"+fileName);
            ClassPathResource resource = new ClassPathResource(fileName);
            InputStream stream = resource.getInputStream();
            content = IOUtils.toString(stream);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }catch (IOException e) {
            logger.error("no file found!", e);
        }

        logger.info("配置文件:{}"+content);
        return content;
    }

 

关注
打赏
1643271353
查看更多评论
立即登录/注册

微信扫码登录

0.0343s