public class Properties extends Object
The Properties class is designed to add new methods not seen in the Properties
class, makes using properties files much easier and extends Javas properties capabilities.
| Constructor and Description |
|---|
Properties()
Creates a new property list with no default values.
|
Properties(boolean ordered)
Creates a new property list with no default values.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all the mappings from this map.
|
boolean |
containsKey(Object key)
Tests if the specified object is a key in this table.
|
String |
getProperty(String key)
A method used to search for a specific property key inside our property list, If the
key is not found, this method will return null
|
String |
getProperty(String key,
Object defaultValue)
A method used to search for a specific property key inside our property list, If the
key is not found, this method will return the specified default property value.
|
boolean |
isEmpty()
Returns
true if this map contains no key-value mappings. |
boolean |
isOrdered()
A method used to return whether a properties are to be in alphabetical order.
|
void |
load(@NotNull File targetFile)
A method used to read a property list (keys and element pairs).
|
void |
load(InputStream inputStream)
A method used to read a property list (keys and element pairs).
|
void |
removeProperty(String key)
A method used to remove a property from a properties map.
|
void |
setProperty(String key,
Object value)
A method used to set a value to a property inside our property list if it
does not already exist.
|
void |
setProperty(String key,
Object value,
boolean replace)
A method used to set a value to a property inside our property list if it
does not already exist.
|
void |
store(@NotNull File targetFile)
A method used to write our properties list (keys and element pairs), in a format
suitable for property loading.
|
void |
store(@NotNull File targetFile,
String comment)
A method used to write our properties list (keys and element pairs), in a format
suitable for property loading.
|
Set<String> |
stringPropertyNames()
A method used to return a set of string property names for a property map.
|
public Properties()
public Properties(boolean ordered)
ordered - Determines whether the property list should be ordered alphabetically.public void store(@NotNull
@NotNull File targetFile,
String comment)
targetFile - Storing location.comment - A description of the property list.ClassCastException - if this Properties object contains any keys or values that are not Strings.NullPointerException - if out is null.store(File)public void store(@NotNull
@NotNull File targetFile)
targetFile - Storing location.ClassCastException - if this Properties object contains any keys or values that are not Strings.NullPointerException - if out is null.store(File, String)public void load(@NotNull
@NotNull File targetFile)
targetFile - File being read.IllegalArgumentException - if the input stream contains a malformed Unicode escape sequence.NullPointerException - if inStream is null.public void load(InputStream inputStream)
inputStream - The input streamIllegalArgumentException - if the input stream contains a malformed Unicode escape sequence.NullPointerException - if inStream is null.public void setProperty(String key, Object value)
key - The target key.value - The desired value.setProperty(String, Object, boolean)public void setProperty(String key, Object value, boolean replace)
key - The target key.value - The desired value.replace - Enable overwriting.setProperty(String, Object)public void removeProperty(String key)
key - Target keypublic String getProperty(String key)
key - The target key.setProperty(String, Object),
setProperty(String, Object, boolean)public String getProperty(String key, Object defaultValue)
key - The target key.defaultValue - A default value.setProperty(String, Object),
setProperty(String, Object, boolean)public boolean isEmpty()
true if this map contains no key-value mappings.true if this map contains no key-value mappingspublic boolean isOrdered()
public boolean containsKey(Object key)
key - possible keytrue if and only if the specified object
is a key in this table, as determined by the
equals method; false otherwiseNullPointerException - if the specified key is nullpublic Set<String> stringPropertyNames()
public void clear()
Copyright © 2022. All rights reserved.