我有以下 Ini 文件
[Test]
a=1
b=2
a=3
我需要这些键值对以正确的顺序。我的问题是,我找不到实现这一目标的方法。我尝试了以下三个选项:
Ini ini = new Ini(new File("test.ini"));
for (String sectionName : ini.keySet()) {
Section section = ini.get(sectionName);
//run through keyset
for (String key : section.keySet()) {
System.out.println(key + " = " + section.get(key));
}
System.out.println();
//run through all values
for (String key : section.keySet()) {
List<String> list = section.getAll(key);
for (String value : list) {
System.out.println(key + " = " + value);
}
}
System.out.println();
//run through entries
Set<Entry<String,String>> se = section.entrySet();
for(Entry<String,String> e:se){
System.out.println(e.getKey() + " = " + e.getValue());
}
}
但我得到的是:
a = 3
b = 2
a = 1
a = 3
b = 2
b = 2
a = 3
这些都不是正确的顺序或包含所有值:(
//编辑:正确的顺序应该像ini文件:
a=1
b=2
a=3