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()
Clears this hashtable so that it contains no keys.
|
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 def)
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.
|
Enumeration<Object> |
keys()
Returns an enumeration of the keys in this hashtable.
|
Set<Object> |
keySet()
Returns a
Set view of the keys contained in this map. |
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 |
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 |
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.public String getProperty(String key)
key - The target key.setProperty(String, Object)public String getProperty(String key, Object def)
key - The target key.def - A default value.setProperty(String, Object)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 boolean isEmpty()
true if this map contains no key-value mappings.true if this map contains no key-value mappingspublic boolean isOrdered()
public void clear()
public Set<Object> keySet()
Set view of the keys contained in this map.
The set is backed by the map, so changes to the map are
reflected in the set, and vice-versa. If the map is modified
while an iteration over the set is in progress (except through
the iterators own remove operation), the results of
the iteration are undefined. The set supports element removal,
which removes the corresponding mapping from the map, via the
Iterator.remove, Set.remove,
removeAll, retainAll, and clear
operations. It does not support the add or addAll
operations.public Enumeration<Object> keys()
Enumeration,
keySet(),
MapCopyright © 2022. All rights reserved.