public class PropertiesConfiguration extends Object
| Constructor and Description |
|---|
PropertiesConfiguration() |
PropertiesConfiguration(java.nio.file.Path path)
Initialize a set of configuration properties from the contents of a properties file.
|
PropertiesConfiguration(String path) |
| Modifier and Type | Method and Description |
|---|---|
int |
getInt(String name,
int def)
Retrieve the value of an integer property.
|
String |
getString(String name)
Retrieve the value of a string property.
|
void |
load(java.nio.file.Path path)
Load property values from the specified properties file.
|
void |
save(java.nio.file.Path path)
Persist all property values to the specified file.
|
void |
setAutoSave(boolean save)
Specify whether or not changes to property values should be automatically persisted to the
properties file.
|
void |
setProperty(String name,
int value)
Set the value of an integer property.
|
void |
setProperty(String name,
String value)
Set the value of a string property.
|
PropertiesConfiguration |
subset(String prefix)
Extract all property values whose name contains the specifed prefix (dot-separated property names).
|
public PropertiesConfiguration()
public PropertiesConfiguration(java.nio.file.Path path) throws IOException, URISyntaxException
path - pathname of the file from which to load the initial property valuesIOExceptionURISyntaxExceptionpublic PropertiesConfiguration(String path) throws IOException, URISyntaxException
IOExceptionURISyntaxExceptionpublic String getString(String name)
name - name of the property value to retrievepublic int getInt(String name, int def)
name - name of the property value to retrievedef - default value to use if no value existspublic void setProperty(String name, String value) throws IOException
name - name of the property value to setvalue - new valueIOExceptionpublic void setProperty(String name, int value) throws IOException
name - name of the property value to setvalue - new valueIOExceptionpublic void setAutoSave(boolean save)
save - true if changes to property values should be automatically persisted.public void load(java.nio.file.Path path) throws IOException
path - pathname to file from which to load property valuesIOExceptionpublic void save(java.nio.file.Path path) throws IOException
path - pathname to the file in which to persist the property valuesIOExceptionpublic PropertiesConfiguration subset(String prefix) throws IOException
prefix - property name prefixIOExceptionCopyright © 2018. All rights reserved.