从文件获取参数
package com.ctd.cloud.manager.util;
import com.ctd.cloud.apps.platform.utils.CostCenterConfig;
import org.apache.log4j.Logger;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
- Copyright 2018 goclouds. All Rights Reserved.
- @author 冯金金. Email:fengjinjin@goclouds.cn
- @version 1.0, 2018-12-11 15:28
- /
public class ManagerConfig {
private static final Logger log = Logger.getLogger(ManagerConfig.class); private static String configFile = "/manager.properties"; private static Properties prop = new Properties(); static { InputStream is = ManagerConfig.class.getResourceAsStream(configFile); if (is == null) { log.error(configFile + "文件不存在,请检查"); } else { try { prop.load(is); } catch (Exception e) { log.error("读取" + configFile + "出错:" + e.getMessage()); } finally { if (is != null) { try { is.close(); } catch (IOException e) { log.error("关闭IO流出错:" + e.getMessage()); } } } } } public static String getProperty(String key){ return prop.getProperty(key); } public static String getRootPath(){ return "/" + prop.getProperty("sysGroupNum"); }
}