类 PropertiesLoaderUtils
- java.lang.Object
- org.springframework.core.io.support.PropertiesLoaderUtils
public abstract class PropertiesLoaderUtils extends Object
Convenient utility methods for loading ofjava.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.
- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller, Rob Harrop
- 另请参阅:
PropertiesLoaderSupport
构造器概要
构造器 构造器 说明 PropertiesLoaderUtils()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static void
fillProperties(Properties props, Resource resource)
Fill the given properties from the given resource (in ISO-8859-1 encoding).static void
fillProperties(Properties props, EncodedResource resource)
Fill the given properties from the given EncodedResource, potentially defining a specific encoding for the properties file.static Properties
loadAllProperties(String resourceName)
Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the default class loader.static Properties
loadAllProperties(String resourceName, ClassLoader classLoader)
Load all properties from the specified class path resource (in ISO-8859-1 encoding), using the given class loader.static Properties
loadProperties(Resource resource)
Load properties from the given resource (in ISO-8859-1 encoding).static Properties
loadProperties(EncodedResource resource)
Load properties from the given EncodedResource, potentially defining a specific encoding for the properties file.
构造器详细资料
PropertiesLoaderUtils
public PropertiesLoaderUtils()
方法详细资料
loadProperties
public static Properties loadProperties(EncodedResource resource) throws IOException
Load properties from the given EncodedResource, potentially defining a specific encoding for the properties file.
fillProperties
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.- 参数:
props
- the Properties instance to load intoresource
- the resource to load from- 抛出:
IOException
- in case of I/O errors
loadProperties
public static Properties loadProperties(Resource resource) throws IOException
Load properties from the given resource (in ISO-8859-1 encoding).- 参数:
resource
- the resource to load from- 返回:
- the populated Properties instance
- 抛出:
IOException
- if loading failed- 另请参阅:
fillProperties(java.util.Properties, Resource)
fillProperties
public static void fillProperties(Properties props, Resource resource) throws IOException
Fill the given properties from the given resource (in ISO-8859-1 encoding).- 参数:
props
- the Properties instance to fillresource
- the resource to load from- 抛出:
IOException
- if loading failed
loadAllProperties
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.
- 参数:
resourceName
- the name of the class path resource- 返回:
- the populated Properties instance
- 抛出:
IOException
- if loading failed
loadAllProperties
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.
- 参数:
resourceName
- the name of the class path resourceclassLoader
- the ClassLoader to use for loading (ornull
to use the default class loader)- 返回:
- the populated Properties instance
- 抛出:
IOException
- if loading failed