• 简单的读取配置文件的工具类


    import java.util.HashMap;

    import java.util.Map;

    import java.util.Properties;

    import org.springframework.beans.BeansException;

    import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

    import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

     

    public class PropertiesUtil

      extends PropertyPlaceholderConfigurer

    {

      private static Map<String, Object> ctxPropertiesMap = new HashMap();

      

      protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)

        throws BeansException

      {

        super.processProperties(beanFactoryToProcess, props);

        for (Object key : props.keySet())

        {

          String keyStr = key.toString();

          String value = props.getProperty(keyStr);

          ctxPropertiesMap.put(keyStr, value);

        }

      }

      

      public static Object getContextProperty(String name)

      {

        return ctxPropertiesMap.get(name);

      }

      

      public static String getContexrtParam(String name)

      {

        return (String)ctxPropertiesMap.get(name);

      }

      

      public static void load(Map map)

      {

        if ((map != null) && (!map.isEmpty())) {

          for (Object key : map.keySet()) {

            ctxPropertiesMap.put(key.toString(), map.get(key));

          }

        }

      }

    }

  • 相关阅读:
    lintcode:落单的数
    lintcode: 翻转链表
    lintcode :Reverse Words in a String 翻转字符串
    lintcode :Invert Binary Tree 翻转二叉树
    lintcode : 空格替换
    lintcode:Matrix Zigzag Traversal 矩阵的之字型遍历
    lintcode: 爬楼梯
    lintcode:Compare Strings 比较字符串
    lintcode: 有效的括号序列
    lintcode :Valid Palindrome 有效回文串
  • 原文地址:https://www.cnblogs.com/tom-plus/p/7581439.html
Copyright © 2020-2023  润新知