How to read sub group values from .ini file in java?

旧时模样 提交于 2019-12-13 04:47:38

问题


i have .ini file with following structure:

    [HEADING1][SUBHEADING]
    DBUSer=John
    DBPASSWD=Joe1234

i am not able to read values from the subgroup(SUBHEADING) of group (HEADING1).I tried hard to search not net but not find any hint, please share your view on that.

i am able to read .ini file with this structure:

    [HEADING1]
    DBUSer=John
    DBPASSWD=Joe1234

but for subgroup i am facing problem.

   Ini ini = new Ini(new File("/path/to/file"));
   System.out.println(ini.get("HEADING1", "DBUSer"));

or if you have any other solution or library please share it here.


回答1:


I haven't tried this, but according to the documentation this should be possible by using the TreeModel:

Ini ini = new Ini(new File("/path/to/file"));
System.out.println(ini.get("HEADING1/SUBHEADING", "DBUSer"));

You can find a sample here ( method sample05() ).



来源:https://stackoverflow.com/questions/19490450/how-to-read-sub-group-values-from-ini-file-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!