diff options
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("配置加载失败"); + } + } + +} |
