Top Description Fields Constructors Methods
org.springframework.core.io.support

public abstract Class PropertiesLoaderUtils

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, .Reader, java.net.URL, .URLConnection, java.util.Enumeration, .Properties, org.springframework.core.io.Resource, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils, .DefaultPropertiesPersister, .PropertiesPersister, .ResourceUtils

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.

Authors
Juergen Hoeller, Rob Harrop, Sebastien Deleuze
Since
2.0
See Also
PropertiesLoaderSupport

Field Summary

Modifier and TypeField and Description
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
fillProperties(Properties
the Properties instance to load into
props
,
EncodedResource
the resource to load from
resource
)

Fill the given properties from the given EncodedResource, potentially defining a specific encoding for the properties file.

pack-priv static void
fillProperties(Properties
the Properties instance to load into
props
,
EncodedResource
the resource to load from
resource
,
PropertiesPersister
the PropertiesPersister to use
persister
)

Actually load properties from the given EncodedResource into the given Properties instance.

public static void
fillProperties(Properties
the Properties instance to fill
props
,
Resource
the resource to load from
resource
)

Fill the given properties from the given resource (in ISO-8859-1 encoding).

public static Properties

Returns:

the populated Properties instance
loadAllProperties
(String
the name of the class path resource
resourceName
)

Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the default class loader.

public static Properties

Returns:

the populated Properties instance
loadAllProperties
(String
the name of the class path resource
resourceName
,
ClassLoader
the ClassLoader to use for loading (or null to use the default class loader)
classLoader
)

Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the given class loader.

public static Properties
loadProperties(EncodedResource resource)

Load properties from the given EncodedResource, potentially defining a specific encoding for the properties file.

public static Properties

Returns:

the populated Properties instance
loadProperties
(Resource
the resource to load from
resource
)

Load properties from the given resource (in ISO-8859-1 encoding).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

XML_FILE_EXTENSIONback to summary
private static final String XML_FILE_EXTENSION

Constructor Detail

PropertiesLoaderUtilsback to summary
public PropertiesLoaderUtils()

Method Detail

fillPropertiesback to summary
public static void fillProperties(Properties props, EncodedResource resource) throws IOException

Fill the given properties from the given EncodedResource, potentially defining a specific encoding for the properties file.

Parameters
props:Properties

the Properties instance to load into

resource:EncodedResource

the resource to load from

Exceptions
IOException:
in case of I/O errors
fillPropertiesback to summary
pack-priv static void fillProperties(Properties props, EncodedResource resource, PropertiesPersister persister) throws IOException

Actually load properties from the given EncodedResource into the given Properties instance.

Parameters
props:Properties

the Properties instance to load into

resource:EncodedResource

the resource to load from

persister:PropertiesPersister

the PropertiesPersister to use

Exceptions
IOException:
in case of I/O errors
fillPropertiesback to summary
public static void fillProperties(Properties props, Resource resource) throws IOException

Fill the given properties from the given resource (in ISO-8859-1 encoding).

Parameters
props:Properties

the Properties instance to fill

resource:Resource

the resource to load from

Exceptions
IOException:
if loading failed
loadAllPropertiesback to summary
public static Properties loadAllProperties(String resourceName) throws IOException

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:String

the name of the class path resource

Returns:Properties

the populated Properties instance

Exceptions
IOException:
if loading failed
loadAllPropertiesback to summary
public static Properties loadAllProperties(String resourceName, 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:String

the name of the class path resource

classLoader:ClassLoader

the ClassLoader to use for loading (or null to use the default class loader)

Returns:Properties

the populated Properties instance

Exceptions
IOException:
if loading failed
loadPropertiesback to summary
public static Properties loadProperties(EncodedResource resource) throws IOException

Load properties from the given EncodedResource, potentially defining a specific encoding for the properties file.

See Also
fillProperties(java.util.Properties, EncodedResource)
loadPropertiesback to summary
public static Properties loadProperties(Resource resource) throws IOException

Load properties from the given resource (in ISO-8859-1 encoding).

Parameters
resource:Resource

the resource to load from

Returns:Properties

the populated Properties instance

Exceptions
IOException:
if loading failed
See Also
fillProperties(java.util.Properties, Resource)