public class ConfigUtils
extends java.lang.Object
| 构造器和说明 |
|---|
ConfigUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static java.util.Properties |
loadAllProperties(java.lang.String propFile,
java.lang.String confFolder,
java.lang.String envVar,
java.lang.Class<?> clazz,
boolean showProp)
顺序加载不同位置的properties文件,加载顺序为:
1.调用 ClassLoader.getResource(String)方法在clazz所在位置查找,如果失败则抛出异常2.如果class在jar包中,则尝试读取在jar所在位置.. |
static java.util.Properties |
loadProperties(java.io.File propPath)
load properties with the parameters given in the given local file path
propPath to Properties |
static java.util.Properties |
loadPropertiesInUserHome(java.util.Properties defProps,
java.lang.String propPath)
基于user.home,加载相对路径propPath指定的properties文件
|
static java.util.Properties |
loadPropertiesInUserHome(java.lang.String propPath)
基于user.home,加载相对路径propPath指定的properties文件
|
static void |
storePropertiesInUserHome(java.util.Properties properties,
java.lang.String propertiesFile)
基于user.home,保存指定的
Properties |
public static java.util.Properties loadAllProperties(java.lang.String propFile,
java.lang.String confFolder,
java.lang.String envVar,
java.lang.Class<?> clazz,
boolean showProp)
ClassLoader.getResource(String)方法在clazz所在位置查找,如果失败则抛出异常propFile - 要加载的properties文件名,为null或空时抛出异常 IllegalArgumentExceptionconfFolder - popFile所在文件夹,null时使用默认值'conf'envVar - 环境变量名 用于定义propFile位置,可为nullclazz - 用于获取 ClassLoader的类,为null时使用本类的classshowProp - 加载后是否显示所有值Properties对象public static java.util.Properties loadPropertiesInUserHome(java.util.Properties defProps,
java.lang.String propPath)
defProps - 默认配置,可为nullpropPath - Properties对象public static java.util.Properties loadPropertiesInUserHome(java.lang.String propPath)
propPath - Properties对象public static void storePropertiesInUserHome(java.util.Properties properties,
java.lang.String propertiesFile)
throws java.io.IOException
Propertiesproperties - propertiesFile - properties文件名java.io.IOExceptionProperties.store(java.io.Writer, String),
System.getProperties()public static java.util.Properties loadProperties(java.io.File propPath)
throws java.io.IOException
propPath to PropertiespropPath - the resource filename to be usedProperties instancejava.io.IOExceptionCopyright © 2023. All Rights Reserved.