Class PropertiesLoaderUtils
java.lang.Object
org.springframework.core.io.support.PropertiesLoaderUtils
Convenient utility methods for loading of
java.util.Properties,
performing standard handling of input streams.
For more configurable properties loading, including the option of a customized encoding, consider using the PropertiesLoaderSupport class.
- Since:
- 2.0
- Author:
- Juergen Hoeller, Rob Harrop, Sebastien Deleuze
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfillProperties(Properties props, Resource resource) Fill the given properties from the given resource (in ISO-8859-1 encoding).static voidfillProperties(Properties props, EncodedResource resource) Fill the given properties from the given EncodedResource, potentially defining a specific encoding for the properties file.static PropertiesloadAllProperties(String resourceName) Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the default class loader.static PropertiesloadAllProperties(String resourceName, ClassLoader classLoader) Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the given class loader.static PropertiesloadProperties(Resource resource) Load properties from the given resource (in ISO-8859-1 encoding).static PropertiesloadProperties(EncodedResource resource) Load properties from the given EncodedResource, potentially defining a specific encoding for the properties file.
-
Constructor Details
-
PropertiesLoaderUtils
public PropertiesLoaderUtils()
-
-
Method Details
-
loadProperties
Load properties from the given EncodedResource, potentially defining a specific encoding for the properties file.- Throws:
IOException- See Also:
-
fillProperties
Fill the given properties from the given EncodedResource, potentially defining a specific encoding for the properties file.- Parameters:
props- the Properties instance to load intoresource- the resource to load from- Throws:
IOException- in case of I/O errors
-
loadProperties
Load properties from the given resource (in ISO-8859-1 encoding).- Parameters:
resource- the resource to load from- Returns:
- the populated Properties instance
- Throws:
IOException- if loading failed- See Also:
-
fillProperties
Fill the given properties from the given resource (in ISO-8859-1 encoding).- Parameters:
props- the Properties instance to fillresource- the resource to load from- Throws:
IOException- if loading failed
-
loadAllProperties
Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the default class loader.Merges properties if more than one resource of the same name found in the class path.
- Parameters:
resourceName- the name of the class path resource- Returns:
- the populated Properties instance
- Throws:
IOException- if loading failed
-
loadAllProperties
public static Properties loadAllProperties(String resourceName, @Nullable ClassLoader classLoader) throws IOException Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the given class loader.Merges properties if more than one resource of the same name found in the class path.
- Parameters:
resourceName- the name of the class path resourceclassLoader- the ClassLoader to use for loading (ornullto use the default class loader)- Returns:
- the populated Properties instance
- Throws:
IOException- if loading failed
-