简体   繁体   中英

Ini4j.jar doesnt work with registry file in java

After adding new section to reg file with key and value, using the store() method to save changes in the file, The new section is added in parts more then once. my code:

File file = new File("2.reg");
Reg reg = new Reg(file);
Key key = reg.add("AA\BB\CC");
key.add("dd","dd");
reg.store();

after store() the reg file has 3 new levels and looks like:

[AA]
[AA\BB]
[AA\BB\CC]
"dd"="dd"

If there is key=empty string like: "vv"="", after load() the string is changed without the value-> "vv"= and the file cannot be loaded again:

File file = new File("2.reg");
Reg reg = new Reg(file);
Evaluation failed. Reason(s):
An exception occurred: java.lang.StringIndexOutOfBoundsException

please help. Thanks

Key key = reg.add("AA\\BB\\CC");

This line of your code wont be compile because it contains escape character (sequence)

check this link for more details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM