【Java开源代码栏目提醒】:网学会员为广大网友收集整理了,ConfigHand.java,希望对大家有所帮助!
package com.example.util;
import java.util.Properties;
import java.io.InputStream;
import java.io.IOException;
public class ConfigHand {
private ConfigHand() {
}
private static Properties prop = null;
public synchronized static Properties getConfigParams() {
if (prop == null) {
prop = new Properties();
ClassLoader cLoader = Thread.currentThread().getContextClassLoader();
InputStream in = cLoader.getResourceAsStream("conf/oc.properties");
try {
prop.load(in);
}
catch (IOException ex) {
System.err.print("配置文件未找到!\n" + ex.getMessage());
throw new RuntimeException("配置文件读取错误");
}
}
return prop;
}
public static String getValue(String paramName) {
String value = null;
value = getConfigParams().getProperty(paramName).trim();
return value;
}
}
上一篇:
Config.java
下一篇:
不规则零件优化排样的神经网络混合优化算法