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 valuesIOException
URISyntaxException
public PropertiesConfiguration(String path) throws IOException, URISyntaxException
IOException
URISyntaxException
public 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 valueIOException
public void setProperty(String name, int value) throws IOException
name
- name of the property value to setvalue
- new valueIOException
public 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 valuesIOException
public void save(java.nio.file.Path path) throws IOException
path
- pathname to the file in which to persist the property valuesIOException
public PropertiesConfiguration subset(String prefix) throws IOException
prefix
- property name prefixIOException
Copyright © 2018. All rights reserved.