zoukankan      html  css  js  c++  java
  • java 得到配置信息

    STEP1: 得到资源文件 com.carel.supervisor.base.config.supervisor.properties
    private static ResourceBundle resourceBundle = ResourceBundle.getBundle(
                "com.carel.supervisor.base.config.supervisor");

    STEP2: 
    resourceBundle.getString("PRODUCT_NAME");




    String name = "carel.properties";
    ClassLoader classLoader = Thread.currentThread()
                                                    .getContextClassLoader();
    URL url = classLoader.getResource(name);
    InputStream input = url.openStream();
    Properties newProperties = new Properties();
    newProperties.load(input);
     Enumeration keys = newProperties.keys();

     while (keys.hasMoreElements())
                {
                    String key = (String) keys.nextElement();

                    if (!propertiesTmp.containsKey(key))
                    {
                        propertiesTmp.setProperty(key,
                            newProperties.getProperty(key));
                        added = true;
                    }
                }



    读取XML类型的配置信息
    = classLoader.getResource(name);
    XMLNode xmlNode = XMLNode.parse(urlService.openStream());

    得到环境变量
    path = System.getenv(PVPRO_HOME);

  • 相关阅读:
    Add Two Numbers
    Reverse Linked List II
    Reverse Linked List
    Remove Duplicates from Sorted List
    Remove Duplicates from Sorted List II
    Partition List
    Intersection of Two Linked Lists
    4Sum
    3Sum
    2Sum
  • 原文地址:https://www.cnblogs.com/kevinge/p/1280987.html
Copyright © 2011-2022 走看看