java静态读配置文件

/**
* 读配置文件
* @param configPath 配置文件路径
* @param key
* @return
*/
public static String getPropertyFromConfigByKey(String configPath, String key){
Properties pros=new Properties();
InputStream is=Utils.class.getResourceAsStream(configPath);
try {
pros.load(is);
} catch (IOException e) {
e.printStackTrace();
}
String iispath=pros.getProperty(key);
return iispath;
}
原文地址:https://www.cnblogs.com/xuhj/p/4285539.html