开发者

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

This question already has answers here: What is the easiest way to parse an INI file in Java? (13 answers) Cl开发者_JAVA技巧osed 7 years ago.

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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜