An initialization or ini file is a configuration file tpically found on Microsoft's Windows operating system and contains data for Windows based applications.
Although popularized by Windows, ini files can be used on any system or platform due to the fact that they are merely text files that can easily be parsed and modified by both humans and computers.
A typcial ini file could look something like:
[section1]
; this is a comment!
var1 = foo
var2 = bar
[section2]
var1 = doo
The format of ini files is fairly straight forward and is composed of three components:
key = value
format.There are various implementations of the ini file format by various vendors which has caused a number of differences to appear. As far as possible this configuration tries to be lenient and support most of the differences.
Some of the differences supported are as follows:
var1 : foo
.Global parameters are also allowed; any parameters declared before a section is declared are added to a global section. It is important to note that this global section does not have a name.
In all instances, a parameter's key is prepended with its section name and a '.' (period). Thus a parameter named "var1" in "section1" will have the key section1.var1
in this configuration. Thus, a section's parameters can easily be retrieved using the subset
method using the section name as the prefix.
default = ok
[section1]
var1 = foo
var2 = doodle
[section2]
; a comment
var1 = baz
var2 = shoodle
bad =
= worse
[section3]
# another comment
var1 : foo
var2 : bar
var5 : test1
[section3]
var3 = foo
var4 = bar
var5 = test2
This ini file will be parsed without error. Note:
getProperty("default")
.getProperty("section1.var1")
.getProperty("section2.")
, notice the period '.' following the section name. The set of sections in this configuration can be retrieved using the getSections
method.
Note:Configuration objects of this type can be read concurrently by multiple threads. However if one of these threads modifies the object, synchronization has to be performed manually.
@author Trevor Miller @version $Id: INIConfiguration.java 589380 2007-10-28 16:37:35Z oheger $ @since 1.4
|
|
|
|
|
|
|
|
|
|
|
|
|
|