From af1c45601cacb24740c182d93bb9caef6a8f757e Mon Sep 17 00:00:00 2001 From: thinkgem Date: Sat, 15 May 2021 21:23:05 +0800 Subject: [PATCH] =?UTF-8?q?PropertiesUtils=20=E5=A2=9E=E5=8A=A0=20getPrope?= =?UTF-8?q?rtyToBoolean=E3=80=81getPropertyToInteger=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jeesite/common/io/PropertiesUtils.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java b/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java index 9dbbfe88..0e0add4a 100644 --- a/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java +++ b/common/src/main/java/com/jeesite/common/io/PropertiesUtils.java @@ -198,12 +198,28 @@ public class PropertiesUtils { } /** - * 取出String类型的Property,但以System的Property优先,如果都为null则返回defaultValue值 + * 获取配置文件中String类型的值,但以System的Property优先,如果都为null则返回defaultValue值 */ public String getProperty(String key, String defaultValue) { String value = getProperty(key); return value != null ? value : defaultValue; } + + /** + * 获取配置文件中Boolean类型的值,取不到从System.getProperty获取,取不到,返回空。 + * @return 获取不到,返回空defValue默认值 + */ + public Boolean getPropertyToBoolean(String key, String defValue) { + return ObjectUtils.toBoolean(getProperty(key, defValue)); + } + + /** + * 获取配置文件中Integer类型的值,取不到从System.getProperty获取,取不到,返回空。 + * @return 获取不到,返回空defValue默认值 + */ + public Integer getPropertyToInteger(String key, String defValue) { + return ObjectUtils.toInteger(getProperty(key, defValue)); + } /** * 设置环境属性