properites配置文件与它的工具类

 配置文件

weixinpay.properties  配置文件

##weixin_pay_APPID
WeiXin_AppId = wxfce80d1dsf934765793
##åweixin_pay_mch_id
WeiXin_MCH_ID=15035236491
##weixin_pay_NOTIFY_URL
WeiXin_NOTIFY_URL=m.wdefs.com/product/app/weiXinPayNotify
##weixin_pay_Refund_Url
WeiXin_Refund_Url=C:/apiclient_cert/apiclient_cert.p12
##
WeiXin_Secret_Key= 
##weixin_pay_Sign_Key
WeiXin_Sign_Key=VrYzT4sdDoCSGSCpKYWMZ3ZQy11fk2V

 
 

工具类  PropertiesUtil

	/**
	 * 
	 * <p>
	 * Title: getProperty
	 * </p>
	 * <p>
	 * Description:
	 * </p>
	 * 
	 * @param resourcePath
	 *            properties 路径 文件名
	 * @param key
	 *            值对应的键
	 * @return
	 */
	public static String getProperty(String resourcePath, String key) {
		String value = "";
		InputStream in = null;
		try {
			in = PropertiesUtil.class.getClassLoader().getResourceAsStream(resourcePath + ".properties");
			Properties properties = new Properties();
			InputStreamReader inputStreamReader = new InputStreamReader(in, "UTF-8");
			properties.load(inputStreamReader);
			value = (String) properties.get(key);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				in.close();
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return value;
	}

工具类调用配置文件读取所对应的值  WeiXinPayController

     String WeiXin_AppId = PropertiesUtil.getProperty("weixinpay", "WeiXin_AppId"); //安卓
     String WeiXin_MCH_ID = PropertiesUtil.getProperty("weixinpay", "WeiXin_MCH_ID");  //安卓
     String WeiXin_NOTIFY_URL = PropertiesUtil.getProperty("weixinpay", "WeiXin_NOTIFY_URL");  //安卓
     String WeiXin_Refund_Url = PropertiesUtil.getProperty("weixinpay", "WeiXin_Refund_Url");  //安卓
     String WeiXin_Sign_Key = PropertiesUtil.getProperty("weixinpay", "WeiXin_Sign_Key");  //安卓
    

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值