java 读取ini文件

一、情景:须要将硬代码写到文件中,这样之后改动只需改动灵活html

1)txt文件,须要将这code字符串读到代码中,保存成数组java

2)导包:pom.xml添加依赖:数组

<dependency>
    <groupId>org.ini4j</groupId>
    <artifactId>ini4j</artifactId>
    <version>0.5.4</version>
</dependency>

3)要读取文件,确定要复制路径spa

4)读取并打印出:code

  public static void main(String[] args) throws IOException {
        String fileName = "E:\\workspeace\\pkpm\\sgserver-service\\sgserver-construction\\construction-service\\src\\main\\resources\\codeFile";
        Wini ini = new Wini(new File(fileName));
        String codeType = ini.get("qrCode", "code");
        System.out.println(codeType);
        String[] types = StringUtils.split(codeType, ",");
        for (String type : types) {
            System.out.println(type);
        }
    }

5)结果:server

6)想了解ini文件,参考这篇博客xml

相关文章
相关标签/搜索