java读取ini的配置文件

由于项目需求,需要读取这种格式的ini配置文件
[group]
transfergroupname=BTM0
sysloghost=192.168.19.200

[business]
gateway=192.168.1.254
netmask=255.255.255.0

[gap]
netmask=255.255.255.0
[manage]
netmask=255.255.255.0

[remote]
gap=


在google上搜索了一遍,没有得到想要的结果。
后来发现了一个专门原来读取操作ini样式文件的开源工具包 IniEditor

使用起来非常简单
Example code
Here's a minimal example. Suppose, we have this in a file called users.ini:

   [root]
   role = administrator
   last_login = 2003-05-04

   [joe]
   role = author
   last_login = 2003-05-13
Let's load that file, add something to it and save the changes:
   IniEditor users = new IniEditor();
   users.load("users.ini");  //加载
   users.set("root", "last_login", "2003-05-16"); //编辑
   users.addComment("root", "Must change password often");//添加注释
   users.set("root", "change_pwd", "10 days");
   users.addBlankLine("root");
   users.save("users.ini"); //保存

This is how the file turned out:

   [root]
   role = administrator
   last_login = 2003-05-16

   # Must change password often
   change_pwd = 10 days

   [joe]
   role = author
   last_login = 2003-05-13


你可能感兴趣的:(java,Google)