import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* 1 读取src下的配置文件
* 工具类
*/
public class Util {
public Util() {
}
public static Properties prop = null;
private static final String FILENAME = "constant.properties";
public static Properties getPara() {
prop = new Properties();
try {
InputStream is = Util.class.getClassLoader().getResourceAsStream(FILENAME);
prop.load(is);
} catch (Exception e) {
e.printStackTrace();
}
return prop;
}
/**
*
* @param key
* @return
*/
public static String readproperty(String key) {
if(null == prop){
Util.getPara();
}
try {
prop.load(Util.class.getClassLoader().getResourceAsStream(FILENAME));
return prop.getProperty(key);
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
return null;
}
}