package com.itcast.util;
import java.io.IOException;
import java.util.Properties;
public class SetUrl {
static Properties props = new Properties();
/**
* 该函数的功能就是读取一个属性文件,并根据传入的Key参数返回对应的值
* @param key 属性文件里的键
* @return
*/
public static String getUrlAddress(String key){
try {
//因为SetUrl 和 siteUrl.properties是同一个类加载器加载的,所以可以用下面的方法
props.load(SetUrl.class.getClassLoader().getResourceAsStream("siteUrl.properties"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return (String)props.getProperty(key);
}
}