package com.cigna.etl.email.config;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Properties;
import org.apache.log4j.Logger;
public class Config
{
// private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(Contents.BUNDLE_NAME);
protected static final Logger logger = Logger.getLogger(Config.class);
private static final String CONFIG_FILE_NAME = "sysconfig.properties";
private static final Properties pro = new Properties();
static {
logger.debug("Begin Loading sysconfig.properties>>>>>>>>>>>>>>>>");
String path = Config.class.getProtectionDomain().getCodeSource().getLocation().getFile();
System.out.print(path);
logger.debug("Config path one>>>>>>>" + path);
try
{
path = URLDecoder.decode(path, "ISO-8859-1");
String filePath = new File(path).getParentFile().getAbsolutePath() + "//" + "sysconfig.properties";
logger.debug("Config path two>>>>>>>" + filePath);
InputStream ips = new BufferedInputStream(new FileInputStream(filePath));
pro.load(ips);
}
catch (UnsupportedEncodingException e1) {
logger.error(e1.getMessage());
}
catch (IOException e2) {
logger.error(e2.getMessage());
}
logger.debug("sysconfig.properties>>>>>>>>>>>>>>>>" + pro);
logger.debug("End Loading sysconfig.properties>>>>>>>>>>>>>>>>");
}
public static String getConfig(String key)
{
// String result = "";
//
// if(key != null && !"".equals(key.trim()))
// {
// result = RESOURCE_BUNDLE.getString(key);
//
// }
//
// return result;
String result = "";
if ((key != null) && (!("".equals(key.trim())))) {
result = pro.getProperty(key);
}
return result;
}
}
如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!
赞0
添加新评论0 条评论