Apron — Advanced Properties
A better API for accessing Java .properties files
Apron is a library for providing a developer-friendly way for reading and writing Java .properties files. In particular it supports writing changes to a .properties file in the least intrusive way possible.
Short Usage
- Provide a .properties file
1## Apron example ##
2
3# The appName can be changed in-app
4appName = My shiny app
5
6# The default port is 5040.
7# Change it if necessary
8#listenPort = 5040
9
10# This description is only visible in
11# the "About" dialog.
12description = Only a \
13 test project
14
15
16
- Read it and modify some entries
1import de.poiu.apron.PropertyFile;
2
3
4final File file= new File("application.properties");
5final PropertyFile propertyFile= PropertyFile.from(file);
6
7// Read the value of the key "appName"
8final String appName= propertyFile.get("appName");
9
10// Change the value of "appName" to a new value
11propertyFile.set("appName", "My brilliant app");
12
13// Write the PropertyFile back to file
14// by only updating the modified values
15propertyFile.update(file);
16}
- Read the result
1## Apron example ##
2
3# The appName can be changed in-app
4appName = My brilliant app
5
6# The default port is 5040.
7# Change it if necessary
8#listenPort = 5040
9
10# This description is only visible in
11# the "About" dialog.
12description = Only a \
13 test project
14
15
16
License
Apron is licensed under the terms of the Apache license 2.0.