package org.iata.framework.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* 读取的配置文件 配置文件名称为:/iatamail.property(相对于classpath)
*
* @author
* @Date 2008-8-22
*/
public class PropertiesUtil {
/**
* 属性文件在classpath下的相对路径
*/
private static final String propertyFile = "/config.properties";
private static final Log logger = LogFactory.getLog(PropertiesUtil.class);
/**
* 返回制定属性的值
*/
public static String getProperty(String key) {
// 加载属性文件
InputStream stream = PropertiesUtil.class.getResourceAsStream(propertyFile);
// load到property
Properties property=new Properties();
String str = "";
try {
property.load(stream);
// 返回制定属性的值
str = (String)property.get(key);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return str;
}
}