public final class PropertyUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
getBooleanProperty(Properties properties,
String name,
boolean defaultValue)
Retrieves a property value as a boolean.
|
static String |
getSystemProperty(String name)
Gets the value of the system property with the given name, throwing an
exception if the system property is not set.
|
static String |
getSystemProperty(String name,
String defaultValue)
Gets the value of the system property with the given name, returning a
default value if the system property is not set.
|
static Properties |
loadProperties(File file)
Load the properties from the given file.
|
static Properties |
loadProperties(InputStream inputStream)
Load the properties from a byte stream.
|
static Properties |
loadProperties(Reader reader)
Load the properties from a character stream.
|
static void |
setSystemProperty(String name,
String value)
Sets a system property with a given name.
|
public static String getSystemProperty(String name)
name - Name of the system property. Cannot be null nor a blank string.IllegalArgumentException - if not found.public static String getSystemProperty(String name, String defaultValue)
name - Name of the system property. Cannot be null nor a blank string.defaultValue - Default value.public static void setSystemProperty(String name, String value)
name - Name of the system property. Cannot be null nor a blank string.value - Value of the system property. Cannot be null nor a blank string.public static Properties loadProperties(File file) throws FileNotFoundException, IOException
file - Path to properties file.FileNotFoundException - Thrown when the properties files doesn't exist.IOException - Thrown when IO error occurred reading in the properties.public static Properties loadProperties(Reader reader) throws IOException
reader - Character stream containing the properties values. Cannot be null.IOException - Thrown when IO error occurred reading in the properties.public static Properties loadProperties(InputStream inputStream) throws IOException
inputStream - Byte stream containing the properties values. Cannot be null.IOException - Thrown when IO error occurred reading in the properties.public static boolean getBooleanProperty(Properties properties, String name, boolean defaultValue)
properties - Properties object to inspect. Cannot be null.name - Name of the property. Cannot be null nor a blank string.defaultValue - Boolean value to return if the property is not set.Copyright © 2021. All rights reserved.