diff options
| author | zhanghongqing <[email protected]> | 2022-08-09 16:54:16 +0800 |
|---|---|---|
| committer | zhanghongqing <[email protected]> | 2022-08-09 16:54:16 +0800 |
| commit | b3fa11d4b1b5a68d7b04fde5eb6cfbda557927eb (patch) | |
| tree | a49d344e49fc427fbf4cf00aa4963c4d04cd98a4 /src/main/java/com/mesasoft/cn/util/ConfigUtils.java | |
| parent | d8a2be0d094ac9ba2d47c81ebf03b3fe6e34a078 (diff) | |
Diffstat (limited to 'src/main/java/com/mesasoft/cn/util/ConfigUtils.java')
| -rw-r--r-- | src/main/java/com/mesasoft/cn/util/ConfigUtils.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main/java/com/mesasoft/cn/util/ConfigUtils.java b/src/main/java/com/mesasoft/cn/util/ConfigUtils.java new file mode 100644 index 0000000..8aedad0 --- /dev/null +++ b/src/main/java/com/mesasoft/cn/util/ConfigUtils.java @@ -0,0 +1,46 @@ +package com.mesasoft.cn.util; + + +import org.apache.log4j.Logger; + +import java.util.Properties; + +public class ConfigUtils { + private static final Logger LOG = Logger.getLogger(ConfigUtils.class); + private static Properties propCommon = new Properties(); + + public static String getStringProperty(String key) { + return propCommon.getProperty(key); + } + + public static Integer getIntProperty(String key) { + return Integer.parseInt(propCommon.getProperty(key)); + } + + public static Long getLongProperty(String key) { + return Long.parseLong(propCommon.getProperty(key)); + } + + public static Boolean getBooleanProperty(String key) { + return "true".equals(propCommon.getProperty(key).toLowerCase().trim()); + } + + public static String getEffectiveString(String s) { + if (!(s == null)) { + return s.length() == 0 ? null : s; + } else { + return null; + } + } + + static { + try { + propCommon.load(ConfigUtils.class.getClassLoader().getResourceAsStream("sketch.properties")); + + } catch (Exception e) { + propCommon = null; + LOG.error("配置加载失败"); + } + } + +} |
