IniEditor is a small Java library to read and edit INI-style configuration files. Its core feature is that it preserves the general formatting of a loaded INI file: It represents comments, blank lines as well as the order of sections and lines.
inieditor.tar.gz (40 KB, release 4, 8/10/2005)
A Debian package is maintained by Aldous D. Penaranda. It might take a while until this gets uploaded to the Debian archive.
Here's a minimal example. Suppose, we have this in a file called
users.ini:
[root] role = administrator last_login = 2003-05-04 [joe] role = author last_login = 2003-05-13
Let's load that file, add something to it and save the changes:
IniEditor users = new IniEditor();
users.load("users.ini");
users.set("root", "last_login", "2003-05-16");
users.addComment("root", "Must change password often");
users.set("root", "change_pwd", "10 days");
users.addBlankLine("root");
users.save("users.ini");
This is how the file turned out:
[root] role = administrator last_login = 2003-05-16 # Must change password often change_pwd = 10 days [joe] role = author last_login = 2003-05-13
IniEditor is Copyright © 2003-2005, Nik Haldimann. It comes with a BSD-style license: You may use and modify it freely as well as redistribute it under certain conditions. See the LICENSE.txt file in the distribution for details.