How to edit ini in Java?
Try using ini4j (https://mvnrepository.com/artifact/org.ini4j/ini4j).
Be sure to check the behavior as ini4j may not work properly. -> It becomes strange if there is an item with the same variable name.
Maven
<!-- https://mvnrepository.com/artifact/org.ini4j/ini4j -->
<dependency>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<version>0.5.4</version>
</dependency>
Note) The source code is from https://ourcodeworld.com/articles/read/839/how-to-read-parse-from-and-write-to-ini-files-easily-in-java
Wini ini = new Wini(new File("C:\\Users\\sdkca\\Desktop\\myinifile.ini"));
int age = ini.get("owner", "age", int.class);
double height = ini.get("owner", "height", double.class);
String server = ini.get("database", "server");
Wini ini = new Wini(new File("C:\\Users\\sdkca\\Desktop\\myinifile.ini"));
ini.put("block_name", "property_name", "value");
ini.put("block_name", "property_name_2", 45.6);
ini.store();
Wini ini = new Wini(new File("C:\\Users\\sdkca\\Desktop\\myinifile.ini"));
ini.remove("section_name");
ini.store();
Reference https://ourcodeworld.com/articles/read/839/how-to-read-parse-from-and-write-to-ini-files-easily-in-java http://tmyk-h.hateblo.jp/entry/2014/01/31/014937 https://codeday.me/jp/qa/20181218/35503.html
Recommended Posts