how to read a config file with sections using Java [duplicate]

拟墨画扇 提交于 2019-12-07 04:20:32

问题


Given a file containing this:

[upper]
a = A
b = B

[words]
1 = one
2 = two

How do I access these key/values with reference to their headers? Java's Properties() class only handles section-less files.


回答1:


Use the ini4j library (tutorial linked): http://ini4j.sourceforge.net/tutorial/




回答2:


If you are a fan of the Apache Commons offerings, they have a library just for you: Commons Configuration. Commons Configuration reads many more formats other than just the .INI style files.



来源:https://stackoverflow.com/questions/3728823/how-to-read-a-config-file-with-sections-using-java

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