public final class Properties extends Properties implements org.aoju.bus.core.getter.BasicType<String>, org.aoju.bus.core.getter.OptBasicType<String>
defaults| Constructor and Description |
|---|
Properties()
构造
|
Properties(File propertiesFile)
构造
|
Properties(File propertiesFile,
Charset charset)
构造
|
Properties(File propertiesFile,
String charsetName)
构造
|
Properties(Properties properties)
构造,使用URL读取
|
Properties(String path)
构造,使用相对于Class文件根目录的相对路径
|
Properties(String path,
Charset charset)
构造,使用相对于Class文件根目录的相对路径
|
Properties(String path,
Class<?> clazz)
构造,相对于classes读取文件
|
Properties(String path,
Class<?> clazz,
Charset charset)
构造,相对于classes读取文件
|
Properties(String path,
Class<?> clazz,
String charsetName)
构造,相对于classes读取文件
|
Properties(String path,
String charsetName)
构造,使用相对于Class文件根目录的相对路径
|
Properties(URL propertiesUrl)
构造,使用URL读取
|
Properties(URL propertiesUrl,
Charset charset)
构造,使用URL读取
|
Properties(URL propertiesUrl,
String charsetName)
构造,使用URL读取
|
| Modifier and Type | Method and Description |
|---|---|
void |
autoLoad(boolean autoReload)
在配置文件变更时自动加载
|
<T> T |
fillBean(T bean,
String prefix)
将配置文件转换为Bean,支持嵌套Bean
支持的表达式:
|
String |
getAndRemoveStr(String... keys)
获取并删除键值对,当指定键对应值非空时,返回并删除这个值,后边的键对应的值不再查找
|
BigDecimal |
getBigDecimal(String key) |
BigDecimal |
getBigDecimal(String key,
BigDecimal defaultValue) |
BigInteger |
getBigInteger(String key) |
BigInteger |
getBigInteger(String key,
BigInteger defaultValue) |
Boolean |
getBool(String key) |
Boolean |
getBool(String key,
Boolean defaultValue) |
Byte |
getByte(String key) |
Byte |
getByte(String key,
Byte defaultValue) |
Character |
getChar(String key) |
Character |
getChar(String key,
Character defaultValue) |
Date |
getDate(String key) |
Date |
getDate(String key,
Date defaultValue) |
Double |
getDouble(String key) |
Double |
getDouble(String key,
Double defaultValue) |
<E extends Enum<E>> |
getEnum(Class<E> clazz,
String key) |
<E extends Enum<E>> |
getEnum(Class<E> clazz,
String key,
E defaultValue) |
Float |
getFloat(String key) |
Float |
getFloat(String key,
Float defaultValue) |
Integer |
getInt(String key) |
Integer |
getInt(String key,
Integer defaultValue) |
Long |
getLong(String key) |
Long |
getLong(String key,
Long defaultValue) |
Object |
getObj(String key) |
Object |
getObj(String key,
Object defaultValue) |
static Properties |
getProp(String resource)
获得Classpath下的Properties文件
|
static Properties |
getProp(String resource,
Charset charset)
获得Classpath下的Properties文件
|
static Properties |
getProp(String resource,
Class<?> clazz)
获得Classpath下的Properties文件
|
static Properties |
getProp(String resource,
String charsetName)
获得Classpath下的Properties文件
|
Short |
getShort(String key) |
Short |
getShort(String key,
Short defaultValue) |
String |
getStr(String key) |
String |
getStr(String key,
String defaultValue) |
void |
load()
重新加载配置文件
|
void |
load(org.aoju.bus.core.io.resource.Resource resource)
初始化配置文件
|
void |
load(URL url)
初始化配置文件
|
void |
setProperty(String key,
Object value)
设置值,无给定键创建之 设置后未持久化
|
void |
store(String absolutePath)
持久化当前设置,会覆盖掉之前的设置
|
void |
store(String path,
Class<?> clazz)
存储当前设置,会覆盖掉以前的设置
|
<T> T |
toBean(Class<T> beanClass)
将配置文件转换为Bean,支持嵌套Bean
支持的表达式:
|
<T> T |
toBean(Class<T> beanClass,
String prefix)
将配置文件转换为Bean,支持嵌套Bean
支持的表达式:
|
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNamesclear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, valuespublic Properties()
public Properties(String path)
path - 路径public Properties(String path, String charsetName)
path - 相对或绝对路径charsetName - 字符集public Properties(String path, Charset charset)
path - 相对或绝对路径charset - 字符集public Properties(File propertiesFile)
propertiesFile - 配置文件对象public Properties(File propertiesFile, String charsetName)
propertiesFile - 配置文件对象charsetName - 字符集public Properties(File propertiesFile, Charset charset)
propertiesFile - 配置文件对象charset - 字符集public Properties(String path, Class<?> clazz)
path - 相对路径clazz - 基准类public Properties(String path, Class<?> clazz, String charsetName)
path - 相对路径clazz - 基准类charsetName - 字符集public Properties(String path, Class<?> clazz, Charset charset)
path - 相对路径clazz - 基准类charset - 字符集public Properties(URL propertiesUrl)
propertiesUrl - 属性文件路径public Properties(URL propertiesUrl, String charsetName)
propertiesUrl - 属性文件路径charsetName - 字符集public Properties(URL propertiesUrl, Charset charset)
propertiesUrl - 属性文件路径charset - 字符集public Properties(Properties properties)
properties - 属性文件路径public static Properties getProp(String resource)
resource - 资源(相对Classpath的路径)public static Properties getProp(String resource, String charsetName)
resource - 资源(相对Classpath的路径)charsetName - 字符集public static Properties getProp(String resource, Charset charset)
resource - 资源(相对Classpath的路径)charset - 字符集public static Properties getProp(String resource, Class<?> clazz)
resource - 资源(相对Classpath的路径)clazz - 基准类public void load(org.aoju.bus.core.io.resource.Resource resource)
resource - Resourcepublic void load()
public void autoLoad(boolean autoReload)
autoReload - 是否自动加载public Object getObj(String key, Object defaultValue)
getObj in interface org.aoju.bus.core.getter.OptBasicType<String>public Object getObj(String key)
getObj in interface org.aoju.bus.core.getter.BasicType<String>public String getStr(String key, String defaultValue)
getStr in interface org.aoju.bus.core.getter.OptBasicType<String>public String getStr(String key)
getStr in interface org.aoju.bus.core.getter.BasicType<String>public Integer getInt(String key, Integer defaultValue)
getInt in interface org.aoju.bus.core.getter.OptBasicType<String>public Integer getInt(String key)
getInt in interface org.aoju.bus.core.getter.BasicType<String>public Boolean getBool(String key, Boolean defaultValue)
getBool in interface org.aoju.bus.core.getter.OptBasicType<String>public Boolean getBool(String key)
getBool in interface org.aoju.bus.core.getter.BasicType<String>public Long getLong(String key, Long defaultValue)
getLong in interface org.aoju.bus.core.getter.OptBasicType<String>public Long getLong(String key)
getLong in interface org.aoju.bus.core.getter.BasicType<String>public Character getChar(String key, Character defaultValue)
getChar in interface org.aoju.bus.core.getter.OptBasicType<String>public Character getChar(String key)
getChar in interface org.aoju.bus.core.getter.BasicType<String>public Float getFloat(String key)
getFloat in interface org.aoju.bus.core.getter.BasicType<String>public Float getFloat(String key, Float defaultValue)
getFloat in interface org.aoju.bus.core.getter.OptBasicType<String>public Double getDouble(String key, Double defaultValue) throws NumberFormatException
getDouble in interface org.aoju.bus.core.getter.OptBasicType<String>NumberFormatExceptionpublic Double getDouble(String key) throws NumberFormatException
getDouble in interface org.aoju.bus.core.getter.BasicType<String>NumberFormatExceptionpublic Short getShort(String key, Short defaultValue)
getShort in interface org.aoju.bus.core.getter.OptBasicType<String>public Short getShort(String key)
getShort in interface org.aoju.bus.core.getter.BasicType<String>public Byte getByte(String key, Byte defaultValue)
getByte in interface org.aoju.bus.core.getter.OptBasicType<String>public Byte getByte(String key)
getByte in interface org.aoju.bus.core.getter.BasicType<String>public BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
getBigDecimal in interface org.aoju.bus.core.getter.OptBasicType<String>public BigDecimal getBigDecimal(String key)
getBigDecimal in interface org.aoju.bus.core.getter.BasicType<String>public BigInteger getBigInteger(String key, BigInteger defaultValue)
getBigInteger in interface org.aoju.bus.core.getter.OptBasicType<String>public BigInteger getBigInteger(String key)
getBigInteger in interface org.aoju.bus.core.getter.BasicType<String>public <E extends Enum<E>> E getEnum(Class<E> clazz, String key, E defaultValue)
getEnum in interface org.aoju.bus.core.getter.OptBasicType<String>public <E extends Enum<E>> E getEnum(Class<E> clazz, String key)
getEnum in interface org.aoju.bus.core.getter.BasicType<String>public Date getDate(String key, Date defaultValue)
getDate in interface org.aoju.bus.core.getter.OptBasicType<String>public Date getDate(String key)
getDate in interface org.aoju.bus.core.getter.BasicType<String>public String getAndRemoveStr(String... keys)
keys - 键列表,常用于别名public <T> T toBean(Class<T> beanClass)
persion persion.name persons[3] person.friends[5].name ['person']['friends'][5]['name']
T - Bean类型beanClass - Bean类public <T> T toBean(Class<T> beanClass, String prefix)
persion persion.name persons[3] person.friends[5].name ['person']['friends'][5]['name']
T - Bean类型beanClass - Bean类prefix - 公共前缀,不指定前缀传null,当指定前缀后非此前缀的属性被忽略public <T> T fillBean(T bean,
String prefix)
persion persion.name persons[3] person.friends[5].name ['person']['friends'][5]['name']
T - Bean类型bean - Bean对象prefix - 公共前缀,不指定前缀传null,当指定前缀后非此前缀的属性被忽略public void setProperty(String key, Object value)
key - 属性键value - 属性值public void store(String absolutePath) throws org.aoju.bus.core.lang.exception.InstrumentException
absolutePath - 设置文件的绝对路径org.aoju.bus.core.lang.exception.InstrumentException - IO异常,可能为文件未找到Copyright © 2020. All rights reserved.