class="java" name="code">
public class InitData {
private static Properties props;
//load properties files
static{
Properties config =getProperties("config.properties");
props.putAll(config);
}
private static Properties getProperties(String fileName) {
InputStream in = InitData.class.getClassLoader().getResourceAsStream(fileName);
props = new Properties();
try {
props.load(new InputStreamReader(in,"UTF-8"));
} catch (IOException e) {
e.printStackTrace();
}
return props;
}
public static String getProValue(String proKey){
String value = props.getProperty(proKey);
if(value == null || value == ""){
return null;
}
return value;
}
}