码迷,mamicode.com
首页 > 其他好文 > 详细

通过Properties文件配置

时间:2015-04-23 12:35:57      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

package com.phoenix.wistariz.base.consts;

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

import com.ebiz.framework.util.validate.FormatUtil;

public class EmdConst {

private static Properties prop;
public static String EMD_IP = null;
public static int EMD_PORT = 0;
public static String EMD_APPNAME = null;
public static String EMD_OFFICE = null;
public static String EMD_CUSTOMNO = null;
public static String EMD_VALIDATIONNO = null;

public static String MU_AIR=null;
public static String MU_CHANNEL=null;
public static String MU_OFFICECODE=null;
public static String MU_IATANO=null;

static{
if(null==prop){
initEmdProperties();
}
}

public static void initEmdProperties(){
prop=new Properties();
try {
InputStream inp=EmdConst.class.getResourceAsStream("/emdclient.properties");
prop.load(inp);
inp.close();
} catch (IOException e) {
//如果发生IO异常,返回
return;
}
EmdConst.EMD_IP=prop.getProperty("server.ip");
EmdConst.EMD_PORT=FormatUtil.toInt(prop.getProperty("server.port"));
EmdConst.EMD_APPNAME=prop.getProperty("client.app");
EmdConst.EMD_OFFICE=prop.getProperty("client.office");
EmdConst.EMD_CUSTOMNO=prop.getProperty("client.customno");
EmdConst.EMD_VALIDATIONNO=prop.getProperty("client.validationno");

EmdConst.MU_AIR=prop.getProperty("mu.airline");
EmdConst.MU_CHANNEL=prop.getProperty("mu.channel");
EmdConst.MU_OFFICECODE=prop.getProperty("mu.officeno");
EmdConst.MU_IATANO=prop.getProperty("mu.iatano");
}

}

 

资源文件Properties:

server.ip=172.25.5.2
server.port=8091
client.app=muairb2cetd1
client.office=sha777
client.customno=0
client.validationno=2

mu.airline=MU
mu.channel=B2C
mu.officeno=SHA777
mu.iatano=08690450

通过Properties文件配置

标签:

原文地址:http://www.cnblogs.com/shoubianxingchen/p/4449770.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!