服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > 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;
}
}

扫描关注微信公众号