读取properties
/**
*properties配置文件的读操作的辅助类
*/
public class PropertiesUtil {
private static Properties properties = null;
private static Properties configPropertie = null;
private static Properties wxPropertie = null;
private PropertiesUtil() {
}
static {
if (properties == null) {
InputStream inputStream = PropertiesUtils.class.getResourceAsStream("/jdbc.properties");
properties = new Properties();
try {
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
if(configPropertie==null){
InputStream inputStream = PropertiesUtils.class.getResourceAsStream("/config.properties");
configPropertie= new Properties();
try {
configPropertie.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
if(wxPropertie==null){
InputStream inputStream = PropertiesUtils.class.getResourceAsStream("/wx.properties");
wxPropertie= new Properties();
try {
wxPropertie.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public synchronized static String get(String key) {
return properties.getProperty(key);
}
public synchronized static String getConfig(String key) {
return configPropertie.getProperty(key);
}
public synchronized static String getWx(String key) {
return wxPropertie.getProperty(key);
}
}