万用工具包hutool-使用java获取文件地址,并读取其中的文件内容

场景:单纯打jar包时输入json参数必须是转义过的,很麻烦,直接从文件中读取不需要手动转义

1、加入pom文件

<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.5</version>
</dependency>

2、配置setting文件,如(同理,也可以这么配置jdbc信息)

3、main函数下加入

Setting setting = new Setting(new File(fileUrl), CharsetUtil.CHARSET_UTF_8, true);//fileUrl是对应文件的具体地址,如E:/code/f.setting
String uripush=setting.getStr("sendtype");//获取配置文件中的具体参数内容
String json111=setting.getStr("input");




猜你喜欢

转载自www.cnblogs.com/Codingdoudou/p/12964418.html