blob: 8aedad013b441f457d11b170aea53da69e6caddf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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("配置加载失败");
}
}
}
|