从文件获取参数

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;

/**

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");
}

}

全部评论

相关推荐

11-20 22:03
东北大学 Java
用哈基米写的简历,有点夸大,等我后面改谦虚点,能不能找个日常实习,项目是点评和天机,没什么荣誉要不要把蓝桥杯和六级删了算了,实在没门面
程序员花海:日常实习这份简历够用的,等实习之后把实习经历结合业务好好写一下 到时候把实习经历放在项目经历的前面 可以看我主页修改简历的模板
如何写一份好简历
点赞 评论 收藏
分享
11-20 13:39
已编辑
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务