编程开发中如何实现简单属性配置文件-成都快上网建站

编程开发中如何实现简单属性配置文件

小编给大家分享一下编程开发中如何实现简单属性配置文件,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

创新互联建站主要从事成都做网站、网站建设、外贸营销网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务集宁,10余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108

a)属性配置文件portal.conf

article_img_path=search_images/rss_img/

film_img_path=search_images/filmdetail1/

history_img_path=search_images/historycontent333/

advertisement_on=0

advertisement1_url=http://172.21.153.81:8080/advert/ShowAdvertImage.action?frameId=10

b)类文件:

package com.utstar.tvweb.util;

import java.util.Properties;

import java.io.FileInputStream;

import java.io.IOException;

import java.io.InputStream;

publicclass Configextends Properties {

   private StringfileName ="/portal.conf";

   

   public String getFileName() {

     returnfileName;

   }

   publicvoid setFileName(String fileName) {

     this.fileName = fileName;

   }

   public Config()

   {

     try {

          InputStream input = getClass().getResourceAsStream(fileName);

         this.load(input);

      }catch (IOException e) {

          e.printStackTrace();

      }

   }  

}

c)使用:

      Config config = (Config)getBean("config");

     adverseURL1 = config.getProperty("advertisement1_url");

看完了这篇文章,相信你对“编程开发中如何实现简单属性配置文件”有了一定的了解,如果想了解更多相关知识,欢迎关注创新互联行业资讯频道,感谢各位的阅读!


文章标题:编程开发中如何实现简单属性配置文件
文章地址:http://kswjz.com/article/iicdch.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流