首页 > 其他 > 详细

读取properties文件的信息

时间:2017-10-10 15:22:25      阅读:206      评论:0      收藏:0      [点我收藏+]

1、properties配置文件的信息

fcsimage_path=C://FCSImage

2、Java代码

public final class Config {
    private static final Object lock = new Object();
    private static volatile Properties config;
    
    private Config(){}
        
    private static Properties getInstance(){
        if (config == null)
        {
            //double lock check
            synchronized (lock) { // declare a private static Object to use for mutex
                if( config == null ){     // have to do this inside the sync
                    config = new Properties();    
                }
            }
            try {
                config.load(Config.class.getClassLoader().getResourceAsStream("common.properties"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        
        return config;
    }
    
    public static String fcsimage_path() {
        return getInstance().getProperty("fcsimage_path");
    }
    
    
}

 

技术分享

读取properties文件的信息

原文:http://www.cnblogs.com/zhangjinru123/p/7645409.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!