com.github.xiaoyuge5201.prop.PropertyUtil Maven / Gradle / Ivy
package com.github.xiaoyuge5201.prop;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* @author xiaoyuge
*/
public class PropertyUtil {
private static Logger log = LoggerFactory.getLogger(PropertyUtil.class);
private static Properties prop = new Properties();
/**
* 获取文件的值
* @param fileName 文件名称
* @param key key
* @return 返回
*/
public static String getPropertyValue(String fileName, String key) {
InputStream in = PropertyUtil.class.getResourceAsStream(fileName);
String rtnValue = null;
try {
prop.load(in);
rtnValue = prop.getProperty(key).trim();
} catch (IOException e) {
log.error("信息:" + e.toString(), e);
}
return rtnValue;
}
}