package com.ice.common;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class IceProperties {
private IceProperties(){}
private static Properties properties = new Properties();
//初始化
static {
setValue();
}
/**
*
* @param url
* @param key
* @return
*/
private static Properties setValue(){
InputStream inputStream = IceProperties.class.getResourceAsStream(IceConstants.WECHAT_PROPERTIES_URI);
try {
properties.load(inputStream);
return properties;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
//获取value值
public static String getVal(String key){
return properties.getProperty(key);
}
}
测试
@Test
public void testurl(){
System.out.println(IceProperties.getVal(IceConstants.WECHAT_APP_ID));
}