public class PropertyReader extends LogSupport
logger| 构造器和说明 |
|---|
PropertyReader()
初始化读取器,使用classpath根目录作为搜索位置,config.properties作为文件名
|
PropertyReader(String configFile)
初始化读取器,使用classpath根目录作为搜索位置,configFile必须以/开头,搜索顺序为项目classes目录、euler-common的classpath、调用代码所在包的classpath
|
PropertyReader(String configFile,
Class<?> callerClass)
初始化读取器
|
| 限定符和类型 | 方法和说明 |
|---|---|
String |
get(String property) |
String |
get(String property,
String defaultValue) |
boolean |
getBooleanValue(String property,
boolean defaultValue) |
double |
getDoubleValue(String property,
double defaultValue) |
<T extends Enum<T>> |
getEnumValue(String property,
T defaultValue,
boolean toUpperCase)
读取枚举类型的配置
|
int |
getIntValue(String property,
int defaultValue) |
long |
getLongValue(String property,
long defaultValue) |
void |
refresh() |
public PropertyReader()
public PropertyReader(String configFile)
configFile - Properties文件路径,具体搜索规则参考Class.getResource(java.lang.String)public PropertyReader(String configFile, Class<?> callerClass)
configFile - Properties文件路径,具体搜索规则参考Class.getResource(java.lang.String)callerClass - 调用者的Class,用来确定搜索位置public void refresh()
public String get(String property) throws PropertyNotFoundException
public int getIntValue(String property, int defaultValue)
public long getLongValue(String property, long defaultValue)
public double getDoubleValue(String property, double defaultValue)
public boolean getBooleanValue(String property, boolean defaultValue)
Copyright © 2017. All rights reserved.