First step with [ini4j] library. No data model, no interfaces, no design patterns, simply read and write windows .ini files.
Lets read some value from .ini file...
void sample01(String filename) throws IOException { Wini ini = new Wini(new File(filename)); int age = ini.get("happy", "age", int.class); double height = ini.get("happy", "height", double.class); String dir = ini.get("happy", "homeDir");
... assuming there is a section with name happy, which contains at least the following options: age, height and homeDir, something like this:
[happy] age = 99 height = 77.66 homeDir = /home/happy
Now let see how to write values....
void sample02(String filename) throws IOException { Wini ini = new Wini(new File(filename)); ini.put("sleepy", "age", 55); ini.put("sleepy", "weight", 45.6); ini.store();
... and then file will have a section sleepy and this section will contains at least two options: age with value 55 and weight with value 45.6, something like this:
[sleepy] age = 55 weight = 45.6
If you want to know more about this library, read tutorials