`
JadeLuo
  • 浏览: 409579 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
社区版块
存档分类
最新评论

读取配置文件

    博客分类:
  • java
 
阅读更多
    protected Properties load() {
        try {
            Properties prop = new Properties();
            String path = "prop/conf.properties";

            String os = System.getProperty("os.name");
            if (os.toLowerCase().startsWith("win")) {
                path = "/src/prop/conf.properties";
            }  
            InputStream in = new FileInputStream(System.getProperty("user.dir") + File.separator + path);
            prop.load(in);//属性文件将该流加入的可被读取的属性中
            return prop;
        } catch (Exception ex) {
            log.error("加载配置文件异常,系统over@@", ex);
            System.exit(0);
        }
        return null;
    }

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics