Edit ini in Java: ini4j

How to edit ini in Java?

Try using ini4j (https://mvnrepository.com/artifact/org.ini4j/ini4j).

Caution

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

read ini

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");

write ini

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();

Erase the ini section

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

Edit ini in Java: ini4j
Partization in Java
Changes in Java 11
Rock-paper-scissors in Java
Pi in Java
FizzBuzz in Java
[java] sort in list
Read JSON in Java
Interpreter implementation in Java
Make Blackjack in Java
Rock-paper-scissors app in Java
Constraint programming in Java
Put java8 in centos7
NVL-ish guy in Java
Combine arrays in Java
"Hello World" in Java
Callable Interface in Java
Comments in Java source
Azure functions in java
Format XML in Java
Simple htmlspecialchars in Java
Boyer-Moore implementation in Java
Hello World in Java
Use OpenCV in Java
webApi memorandum in java
Type determination in Java
Ping commands in Java
Various threads in java
Heapsort implementation (in java)
Zabbix API in Java
ASCII art in Java
Compare Lists in Java
POST JSON in Java
Express failure in Java
Create JSON in Java
Date manipulation in Java 8
What's new in Java 8
Use PreparedStatement in Java
What's new in Java 9,10,11
Parallel execution in Java
Initializing HashMap in Java
This and that for editing ini in Java. : inieditor-java
Try using RocksDB in Java
Read binary files in Java 1
Get EXIF information in Java
Save Java PDF in Excel
[Neta] Sleep Sort in Java
Java history in this world
Let Java segfault in 6 lines
Try calling JavaScript in Java
Try developing Spresense in Java (1)
Try functional type in Java! ①
I made roulette in Java.
Create hyperlinks in Java PowerPoint
Implement two-step verification in Java
Refactoring: Make Blackjack in Java
Write flyway callbacks in Java
Topic Analysis (LDA) in Java
Importing Excel data in Java 2
NEologd preprocessing in Java neologdn-java
Change java encoding in windows