Class Props
java.lang.Object
com.sure.tool.util.Props
Properties 配置文件增强工具:UTF-8 加载、强类型读取、默认值,零依赖。
覆盖 .properties 中文乱码场景:加载时按指定字符集读取(默认 UTF-8)。
- Since:
- 0.2.0
- Author:
- suretool
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(String key) 是否包含键。boolean取 boolean(true/1/yes 视为 true,忽略大小写)。boolean取 boolean(带默认值)。double取 double。double取 double(带默认值)。int取 int。int取 int(带默认值)。long取 long。long取 long(带默认值)。获取底层 Properties。取字符串。取字符串(带默认值)。加载文件(UTF-8)。load(InputStream in) 加载输入流(UTF-8)。load(InputStream in, Charset charset) 加载输入流(指定字符集,避免中文乱码)。设置键值。toString()
-
Constructor Details
-
Props
public Props()构造空配置。 -
Props
从路径加载(UTF-8)。- Parameters:
path- 文件路径- Throws:
IOException- IO 异常
-
Props
从文件加载(UTF-8)。- Parameters:
file- 文件- Throws:
IOException- IO 异常
-
Props
从输入流加载(UTF-8)。- Parameters:
in- 输入流- Throws:
IOException- IO 异常
-
-
Method Details
-
load
加载文件(UTF-8)。- Parameters:
file- 文件- Returns:
- this
- Throws:
IOException- IO 异常
-
load
加载输入流(UTF-8)。- Parameters:
in- 输入流- Returns:
- this
- Throws:
IOException- IO 异常
-
load
加载输入流(指定字符集,避免中文乱码)。- Parameters:
in- 输入流charset- 字符集- Returns:
- this
- Throws:
IOException- IO 异常
-
getStr
-
getStr
-
getInt
-
getInt
取 int(带默认值)。- Parameters:
key- 键defaultValue- 默认值- Returns:
- int 值
-
getLong
-
getLong
取 long(带默认值)。- Parameters:
key- 键defaultValue- 默认值- Returns:
- long 值
-
getDouble
-
getDouble
取 double(带默认值)。- Parameters:
key- 键defaultValue- 默认值- Returns:
- double 值
-
getBool
取 boolean(true/1/yes 视为 true,忽略大小写)。- Parameters:
key- 键- Returns:
- boolean 值;缺失返回 false
-
getBool
取 boolean(带默认值)。- Parameters:
key- 键defaultValue- 默认值- Returns:
- boolean 值
-
containsKey
-
set
-
getProperties
-
toString
-