Java 读取配置文件

ublic static void initialize(){
  Properties props = new Properties();
  try {
   SERVER_PATH = getServerRoot();
   
   InputStream in = Config.class.getClassLoader().getResourceAsStream("config.properties");
   props.load(in);
   OFFICE_CODE = props.getProperty("office_code", StringUtils.EMPTY);
   CACHE_URL = props.getProperty("cache_url", StringUtils.EMPTY);
   APP_PATH = props.getProperty("app_path", StringUtils.EMPTY);
   CLASS_PATH = APP_PATH + File.separator + "WEB-INF" + File.separator + "classes" + File.separator;
   UPLOAD_PATH = props.getProperty("upload_path", StringUtils.EMPTY);
   
   AIRPORT_TAX10 = props.getProperty("airport_tax", StringUtils.EMPTY);
   PLANE_MODEL1 = props.getProperty("plane_model1", StringUtils.EMPTY);
   PLANE_MODEL2 = props.getProperty("plane_model2", StringUtils.EMPTY);
   PLANE_MODEL3 = props.getProperty("plane_model3", StringUtils.EMPTY);
   BBC_POLICY = props.getProperty("bbc_policy", StringUtils.EMPTY);
   
   SD_LINKMAN = props.getProperty("sd_linkman", StringUtils.EMPTY);
   SD_LINKMAN = new String(SD_LINKMAN.getBytes("ISO-8859-1"), "GBK");
   SD_CONTACT = props.getProperty("sd_contact", StringUtils.EMPTY);
   
   MONGODB_IP = props.getProperty("mongodb_ip",StringUtils.EMPTY);
   MONGODB_PORT = Integer.parseInt(props.getProperty("mongodb_port","27017"));
   MONGODB_DB_NAME = props.getProperty("mongodb_db",StringUtils.EMPTY);
   MONGODB_POOL_SIZE = Integer.parseInt(props.getProperty("mongodb_pool_size","50"));
   MONGODB_USER = props.getProperty("mongodb_user",StringUtils.EMPTY);
   MONGODB_PWD = props.getProperty("mongodb_pwd",StringUtils.EMPTY);
  }
  catch (Exception ex) {
   ex.printStackTrace();
  }
 }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值