Class Properties
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PropertiesThe default values for keys not found in thisPropertiesinstance. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newPropertiesobject.Properties(Properties properties) Constructs a newPropertiesobject using the specified defaultProperties. -
Method Summary
Modifier and TypeMethodDescriptiongetProperty(String name) Searches for the property with the specified name.getProperty(String name, String defaultValue) Searches for the property with the specified name.voidload(InputStream in) Loads properties from the specifiedInputStream, assumed to be ISO-8859-1.voidLoads properties from the specifiedReader.Enumeration<?> Returns all of the property names (keys) in thisPropertiesobject.voidsave(OutputStream out, String comment) Deprecated.setProperty(String name, String value) Maps the specified key to the specified value.voidstore(OutputStream out, String comment) Stores properties to the specifiedOutputStream, using ISO-8859-1.voidStores the mappings in thisPropertiesobject toout, putting the specified comment at the beginning.Returns those property names (keys) in thisPropertiesobject for which both key and value are strings.Methods inherited from class HashMap
clear, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, valuesMethods inherited from class AbstractMap
equals, hashCode, toStringMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
defaults
The default values for keys not found in thisPropertiesinstance.
-
-
Constructor Details
-
Properties
public Properties()Constructs a newPropertiesobject. -
Properties
Constructs a newPropertiesobject using the specified defaultProperties.- Parameters:
properties- the defaultProperties.
-
-
Method Details
-
getProperty
Searches for the property with the specified name. If the property is not found, the defaultPropertiesare checked. If the property is not found in the defaultProperties,nullis returned.- Parameters:
name- the name of the property to find.- Returns:
- the named property value, or
nullif it can't be found.
-
getProperty
Searches for the property with the specified name. If the property is not found, it looks in the defaultProperties. If the property is not found in the defaultProperties, it returns the specified default.- Parameters:
name- the name of the property to find.defaultValue- the default value.- Returns:
- the named property value.
-
load
Loads properties from the specifiedInputStream, assumed to be ISO-8859-1. See "Character Encoding".- Parameters:
in- theInputStream- Throws:
IOException
-
load
Loads properties from the specifiedReader. The properties file is interpreted according to the following rules:- Empty lines are ignored.
- Lines starting with either a "#" or a "!" are comment lines and are ignored.
- A backslash at the end of the line escapes the following newline character ("\r", "\n", "\r\n"). If there's whitespace after the backslash it will just escape that whitespace instead of concatenating the lines. This does not apply to comment lines.
- A property line consists of the key, the space between the key and the value, and the value. The key goes up to the first whitespace, "=" or ":" that is not escaped. The space between the key and the value contains either one whitespace, one "=" or one ":" and any amount of additional whitespace before and after that character. The value starts with the first character after the space between the key and the value.
- Following escape sequences are recognized: "\ ", "\\", "\r", "\n", "\!", "\#", "\t", "\b", "\f", and "\uXXXX" (unicode character).
- Parameters:
in- theReader- Throws:
IOException- Since:
- 1.6
-
propertyNames
Returns all of the property names (keys) in thisPropertiesobject. -
stringPropertyNames
-
save
Deprecated.This method ignores anyIOExceptionthrown while writing -- usestore(OutputStream, String)instead for better exception handling.Saves the mappings in thisPropertiesto the specifiedOutputStream, putting the specified comment at the beginning. The output from this method is suitable for being read by theload(InputStream)method.- Parameters:
out- theOutputStreamto write to.comment- the comment to add at the beginning.- Throws:
ClassCastException- if the key or value of a mapping is not a String.
-
setProperty
-
store
Stores properties to the specifiedOutputStream, using ISO-8859-1. See "Character Encoding".- Parameters:
out- theOutputStreamcomment- an optional comment to be written, or null- Throws:
IOExceptionClassCastException- if a key or value is not a string
-
store
Stores the mappings in thisPropertiesobject toout, putting the specified comment at the beginning.- Parameters:
writer- theWritercomment- an optional comment to be written, or null- Throws:
IOExceptionClassCastException- if a key or value is not a string- Since:
- 1.6
-
IOExceptionthrown while writing -- usestore(OutputStream, String)instead for better exception handling.