public static String
TM_API_SERVER_HOST = PropertiesUtil.getProperty("config/im.properties", "TIM_HOST"
);
public static String getProperty(String resource, String key) {
Properties properties =
PropertiesUtil.getProperties(resource);
return properties.getProperty(key);
}
/**
* 读取properties文件
*
* @param resource
* 文件名称
* @return
*/
public static Properties getProperties(String resource) {
Properties properties =
new Properties();
try {
InputStream is =
Thread.currentThread().getContextClassLoader().getResourceAsStream
(resource);
properties.load(is);
} catch (IOException ioe) {
ioe.printStackTrace();
throw new RuntimeException(ioe);
}
return properties;
}
转载于:https://www.cnblogs.com/wwwcf1982603555/p/9146460.html