百度空间 | 百度首页 
 
查看文章
 
system.properties 文件读取
2007年05月10日 星期四 10:31

package com.config;

import java.io.InputStream;
import java.util.Properties;


public class GlobalConfig {

private static String _ConfigName = "system.properties";//属性文件与class文件在同一目录下
   public static String dd = null;

   public GlobalConfig(){
    init();
   }

   /**
* 读取属性完成初始化
*/
private void init()
{
   
   InputStream is = getClass().getResourceAsStream(_ConfigName);
   Properties dbProps = new Properties();
   try
   {
    dbProps.load(is);
    dd = dbProps.getProperty("TRS_IP");
   }
   catch (Exception e)
   {


    System.err.println("不能读取属性文件. "+"请确保"+_ConfigName+"在WEB_INF/CLASSES路径中");
    return;
   }
}
public static void main(String[] args) {
   new GlobalConfig();
   System.out.print(GlobalConfig.dd);
  
}
}


类别:Jsp | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu