ini4j incorrectly parses .ini files with section name [mm/yyyy]?

383 views Asked by At

I am using ini4j API to parse .ini files, in which the section name is in the format [mm/yyyy], where the / character is causing troubles.

Suppose my test.ini file is as follows:

[02/2018]
k=v

My Java code snippet is:

Ini ini = new Ini(new File("test.ini"));        
Set<String> sectionNames = ini.keySet();  
System.out.println("List of Section Names: " + sectionNames + "\n");

I got the following output:

List of Section Names: [02, 02/2018]

where "02" is mistakenly parsed as a section.

Is this a bug or am I using the API properly?

1

There are 1 answers

2
JJF On

From the documentation at http://ini4j.sourceforge.net/tutorial/IniTutorial.java.html

Tree model Beyond two level map model, Ini class provides tree model. You can access Sections as tree. It means that section names becomes path names, with a path separator character ('/' and '\' on Wini and Reg).

You should be using the Wini class instead of the Ini class