private static Properties properties = new Properties();
private String getPropertyValue(String key) {
loadCodeDip();
String value = (String)properties.get(key);
if(value.equals("")||null == value){
value="";
}else{
try {
value=new String(value.getBytes("ISO8859_1"),"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return value;
}
private static void loadCodeDip(){
try {
properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("config.properties"));
} catch (IOException e) {
e.printStackTrace();
}
}
调用:
String smsUrl = getPropertyValue("URL_PATH_FACTORY_LOGO");
property文件内容
URL_PATH_FACTORY_LOGO=http\://192.168.1.29\:8090/baseDataWebService/v1/writeFactoryPicture