public class PropertyManager extends Object
| Modifier and Type | Field and Description |
|---|---|
private File |
propFile |
private Properties |
props |
| Constructor and Description |
|---|
PropertyManager()
Standard constructor.
|
PropertyManager(File f)
Constructs a
PropertyManager and stores the key-value pairs in
the specified file. |
| Modifier and Type | Method and Description |
|---|---|
static PropertyManager |
getManager(Object o)
Gets a property manager for a
Class name of a specific object. |
String |
getProperty(String key)
Get a specific property by key.
|
File |
getPropFile()
Gets the file of this manager.
|
static void |
main(String[] args) |
Properties |
read()
Reads the current property file.
|
static Properties |
read(File file,
boolean createIfNotExists)
Reads properties from a file.
|
void |
setProperty(String key,
String value)
Sets the property and writes it to the file.
|
void |
setPropFile(File propFile)
Sets the file of this manager.
|
void |
write()
Writes the current property file.
|
static void |
write(Properties props,
File file,
String comment)
Writes properties to a file.
|
private File propFile
private Properties props
public PropertyManager()
public PropertyManager(File f)
PropertyManager and stores the key-value pairs in
the specified file.f - public static void write(Properties props, File file, String comment)
props - file - comment - public static Properties read(File file, boolean createIfNotExists)
file - createIfNotExists - if true, the file will be created and the
properties associated with that file are returned, if
false, the method returns nullProperties objectpublic static PropertyManager getManager(Object o)
Class name of a specific object.
This method instantiates a property file for this class and loads it to
the manager.o - PropertyManager for a given classpublic void setPropFile(File propFile)
propFile - public File getPropFile()
public void setProperty(String key, String value)
key - value - public String getProperty(String key)
key - String, the value associated with the key, or
null if the property is not foundpublic Properties read()
Properties objectpublic void write()
public static void main(String[] args) throws JAXBException
JAXBExceptionCopyright © 2009–2017 Helmut Ahammer, Philipp Kainz. All rights reserved.