程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> JAVA編程入門知識 >> JAVA:配置文件讀取器

JAVA:配置文件讀取器

編輯:JAVA編程入門知識

  〔config.properties〕
  
  [CMS properties]
  cmsServerName=cms
  cmsTemplateDirectoryName=template
  
  [time out:minute]
  time_out=300000
  
  [administrator setting]
  administrator=SA
  admingroup=ADMINROLE
  
  [web path setting]
  innerresource=/AccessControl/jsp/innerresource/
  
  [picture path setting]
  picturePath=C:/picture/
  [log path setting]
  logPath=c:/log1/
  
  
  ConfigBundle.Java
  
  package creator.config;
  
  import java.util.MissingResourceException;
  import java.util.ResourceBundle;
  
  /**
   *
   * <p>Title: ConfigBundle.java</p>
   * <p>Description: </p>
   * <p>Copyright: Copyright (c) 2004</p>
   * <p>Company: </p>
   * @author TanBo
   * @version 1.0
   */
  public class ConfigBundle{
   private static ResourceBundle bundle;
  
   /**
   * init()
   */
   public ConfigBundle()
   {
   }
  
   /**
   * @function getString
   * @param s String
   * @return String
   */
   public static String getString(String s){
   String s1 = null;
   try{
   s1 = getResourceBundle().getString(s);
   }catch(MissingResourceException missingresourceexception){
   System.out.println("ConfigBundle:getString error!"+missingresourceexception.toString());
   }
   return s1;
   }
  
   /**
   * @function getResourceBundle
   * @return ResourceBundle
   */
   private static ResourceBundle getResourceBundle(){
   if(bundle == null)
   bundle = ResourceBundle.getBundle("creator.config.config");
   return bundle;
   }
  }
 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved