• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
开水房
ASP.NET
博客园    首页    新随笔    联系   管理    订阅  订阅
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);

posted on 2008-09-01 10:30  白开水皮皮  阅读(174)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3