public final class PropertiesUtils extends Object
Properties
Modifier and Type | Method and Description |
---|---|
static Properties |
load(String resourceName)
Load properties from the given resources using the current thread context class loader.
|
static Properties |
load(String resourceName,
ClassLoader loader)
Load properties from the given resources using the given class loader.
|
static Properties |
load(URL url)
Load properties from the given URL.
|
static Properties |
loadPropertiesFromFile(File propertiesFile)
Load the properties from a file.
|
static Properties |
loadPropertiesFromFile(String propertiesFileName)
Load the properties from a file.
|
static void |
storePropertiesToFile(Properties properties,
File propertiesFile)
Stores the properties in a file.
|
static void |
storePropertiesToFile(Properties properties,
File propertiesFile,
Charset charset)
Stores the properties in a file.
|
public static Properties load(String resourceName) throws IOException
resourceName
- The resource nameIOException
- in case an error occurred while reading the propertiespublic static Properties load(String resourceName, ClassLoader loader) throws IOException
resourceName
- The resource nameloader
- The class loaderIOException
- in case an error occurred while reading the propertiespublic static Properties load(URL url) throws IOException
Note: this method does not set a read timeout!
url
- the URL to load fromIOException
- in case an error occurred while reading the propertiespublic static Properties loadPropertiesFromFile(File propertiesFile) throws IOException
propertiesFile
- The property fileIOException
- if the file cannot be found or readpublic static Properties loadPropertiesFromFile(String propertiesFileName) throws IOException
propertiesFileName
- The name of the property fileIOException
- if the file cannot be found or readpublic static void storePropertiesToFile(Properties properties, File propertiesFile) throws IOException
properties
- the properties to storepropertiesFile
- The property fileIOException
- if the file cannot be found or writtenpublic static void storePropertiesToFile(Properties properties, File propertiesFile, Charset charset) throws IOException
properties
- the properties to storepropertiesFile
- The property filecharset
- charset to use for encoding the outputIOException
- if the file cannot be found or writtenCopyright © 2019 Communote team. All rights reserved.