zoukankan      html  css  js  c++  java
  • 获取指定配置文件信息utils

    获取指定配置文件信息utils

    import java.util.HashMap;
    import java.util.Map;
    import java.util.ResourceBundle;
    
    public class RemoteConfigUtil {
    
        private static Map<String,ResourceBundle>    configMap    = new HashMap<String, ResourceBundle>();
        
        private  static synchronized void loadResource(String propertyFileName){
            ResourceBundle resource = ResourceBundle.getBundle(propertyFileName);
            configMap.put(propertyFileName, resource);
        }
        
        /**
         * 在指定文件中获取指定的配置属性
         * @param key
         * @param propertyFileName
         * @return
         */
        public static String getValue(String key,String propertyFileName) {
            ResourceBundle resource = configMap.get(propertyFileName);
            if(resource == null){
                loadResource(propertyFileName);
                resource = configMap.get(propertyFileName);
            }
            return resource.getString(key);
        }
        
        /**
         * 在指定文件中获取所有属性集
         * @param propertyFileName
         * @return
         */
        public static ResourceBundle getResources(String propertyFileName){
            ResourceBundle resource = configMap.get(propertyFileName);
            if(resource == null){
                loadResource(propertyFileName);
                resource = configMap.get(propertyFileName);
            }
            return resource;
        }
    }
  • 相关阅读:
    Go语言并发编程
    Go语言package
    大数据实践(十) Spark多种开发语言、与Hive集成
    大数据实践(九)--sqoop安装及基本操作
    Go语言错误处理
    Go语言接口
    Go语言面向对象
    数据库基础了解
    PL/SQL语句快捷输入设置
    重载操作符介绍
  • 原文地址:https://www.cnblogs.com/wangquanyi/p/12106950.html
Copyright © 2011-2022 走看看