• java工具类-读配置文件


    ///读配置文件


    import java.io.InputStream;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Map.Entry;
    import java.util.Properties;
    import java.util.Set;
    public class PropertiesUtils
    {

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

        private PropertiesUtils()
        {
            init();
        }
        private static PropertiesUtils salf = null;

        private  void init()
        {
            InputStream inStream = null;
            try
            {
                String templatePath = "D:\menu.properties";
                inStream = new FileInputStream (templatePath);
                Properties properties = new Properties();
                properties.load (inStream);
                Set<Entry<Object, Object>> proEntrySet = properties.entrySet();
                for (Entry<Object, Object> entry : proEntrySet)
                {
                    propertiesMap.put (entry.getKey() + "", entry.getValue() + "");
                }
            }
            catch (Exception e)
            {
            } finally
            {
            }
        }
        public static String getValue (String key, boolean reLoadFlag)
        {
            if (null == salf)
            {
                salf = new  PropertiesUtils();
            }
            if (reLoadFlag)
            {
                salf.init();
            }
            return salf.propertiesMap.get (key);
        }

        public static String getValue (String key)
        {
            return getValue (  key, false) ;
        }
    }

  • 相关阅读:
    景瑞地产商业智能BI整体实施过程
    域名访问和IP访问问题
    sitemesh定义多个装饰器
    8.8.2 EXPLAIN Output Format 优化输出格式
    Python_List对象内置方法详解
    Python_List对象内置方法详解
    Python_序列对象内置方法详解_String
    Python_序列对象内置方法详解_String
    CentOS设置服务开机启动的两种方法
    perl 没有关键文件句柄引起的逻辑错误
  • 原文地址:https://www.cnblogs.com/heling/p/3874694.html
Copyright © 2020-2023  润新知