技术中心

这里象征着我们的态度和能力

>Java读取指定目录的xml配置文件
发布者:中国IT实验室    信息来源:中国IT实验室    发布时间:2012-01-09      浏览次数:5721
分享到:

新浪微博

腾讯微博

QQ空间

豆瓣网

QQ好友

欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入

  /**

  * Alipay.com Inc.

  * Copyright (c) 2005-2008 All Rights Reserved.

  */

  package com.alipay.client.base;

  import java.io.InputStream;

  import javax.xml.parsers.DocumentBuilder;

  import javax.xml.parsers.DocumentBuilderFactory;

  import org.w3c.dom.Document;

  import org.w3c.dom.Element;

  import org.w3c.dom.NodeList;

  /**

  *

  *

  * @author feng.chenf

  * @version $Id: ClientConfig.java, v 0.1 2008-12-24 ????09:31:39 feng.chenf Exp $

  */

  public class ClientConfig {

  /**

  * ????????????????????? ????????https://wappaygw.alipay.com

  */

  private String serverUrl    = "http://115.124.16.16";

  /**

  * ????????????????????? ???????????????? ?????443???

  */

  private String serverPort   = "80";

  /**

  * ?????partnerId

  */

  private String partnerId    = "";

  /**

  * ??????????ú?

  */

  private String secId        = "";

  /**

  * ???????

  */

  private String prikey       = "";

  /**

  * ???????

  */

  private String pubkey       = "";

  /**

  * ????????????????????

  */

  private String alipayVeriPubKey = "";

  /**

  * ?????????????????????????

  */

  private String alipayEncPubKey = "";

  /**

  * ?????? ?????????????RSA

  */

  private String signAlgo     = "RSA";

  /**

  * ??????? ?????????????RSA

  */

  private String encryptAlgo = "RSA";

  public ClientConfig() {

  try {

  InputStream iss = this.getClass().getClassLoader().getResourceAsStream(

  "com/alipay/client/config/config.xml");

  DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();

  DocumentBuilder dombuilder = domfac.newDocumentBuilder();

  Document doc = dombuilder.parse(iss);

  Element rootElement = doc.getDocumentElement();

  NodeList paramNode = doc.getElementsByTagName("partnerId");

  partnerId = paramNode.item(0).getFirstChild().getNodeValue().trim();

  NodeList secNode = doc.getElementsByTagName("secId");

  secId = secNode.item(0).getFirstChild().getNodeValue().trim();

  NodeList signAlgoNode = doc.getElementsByTagName("signAlgo");

  this.signAlgo = signAlgoNode.item(0).getFirstChild().getNodeValue().trim();

  NodeList prikeyNode = doc.getElementsByTagName("prikey");

  this.prikey = prikeyNode.item(0).getFirstChild().getNodeValue().trim();

  NodeList pubkeyNode = doc.getElementsByTagName("pubkey");

  this.pubkey = pubkeyNode.item(0).getFirstChild().getNodeValue().trim();

  NodeList alipayVeriPubKeyNode = doc.getElementsByTagName("alipayVeriPubKey");

  this.alipayVeriPubKey = alipayVeriPubKeyNode.item(0).getFirstChild().getNodeValue().trim();

  NodeList alipayEncPubKeyNode = doc.getElementsByTagName("alipayEncPubKey");

  this.alipayEncPubKey = alipayEncPubKeyNode.item(0).getFirstChild().getNodeValue().trim();

  } catch (Exception e) {

  //??????

  //??????????? ????????????

  e.printStackTrace();

  }

[1] [2] [3] 下一页

4000-880-989
(24小时热线)
联系客服
微信公众号

官方公众号

小程序

©2008-2022 CORPORATION ALL Rights Reserved. 版权所有 滇ICP备09003328号-1 滇公网安备 53011102000818号
昆明那家网络公司好,新媒体运营,网站优化,网络推广,网站建设,网页设计,网站设计,网站推广,云南网站公司,昆明新媒体公司,云南网红主播,昆明SEO公司,昆明网站建设,昆明网络推广,昆明网站优化,昆明网站推广,红河网站建设,大理网络公司,曲靖网络公司,丽江网站设计,昭通网络公司,保山大数据服务,智慧高速建设,智慧校园服务,云南IDC服务商,网络安全测评,等保测评,网站关键词排名优化服务,服务客户尽超2000余家,一切尽在奥远科技,服务电话:13888956730
Baidu
map