锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲欧洲一区二区,国产亚洲精品仙踪林在线播放,亚洲欧洲国产日韩精品http://m.tkk7.com/stevenjohn/category/52209.html閭d簺闈掓槬鐨勫瞾鏈?/description>zh-cnWed, 15 Aug 2012 01:55:51 GMTWed, 15 Aug 2012 01:55:51 GMT60[杞澆] JDom杈撳嚭UTF-8鐨刋ML鍑虹幇涓枃涔辯爜瀹岀編瑙e喅http://m.tkk7.com/stevenjohn/archive/2012/08/15/385506.htmlabinabinWed, 15 Aug 2012 01:34:00 GMThttp://m.tkk7.com/stevenjohn/archive/2012/08/15/385506.htmlhttp://m.tkk7.com/stevenjohn/comments/385506.htmlhttp://m.tkk7.com/stevenjohn/archive/2012/08/15/385506.html#Feedback0http://m.tkk7.com/stevenjohn/comments/commentRss/385506.htmlhttp://m.tkk7.com/stevenjohn/services/trackbacks/385506.html1錛塉DOM鏄惁鐢熸垚UTF-8鐨勬枃浠朵笌Format鏄惁璁劇疆鏃犲叧錛屽彧鏈夎緭鍑哄叾浠栧瓧絎︾紪鐮佹墠闇瑕佽緗紝瑙佷笅闈㈢殑娉ㄩ噴銆?
2錛塉DOM杈撳嚭UTF-8鏂囦歡涔辯爜鐨勬牴鏈師鍥犲茍闈炲湪JDOMAPI錛岃屾槸鍦↗DK銆?
鍏蜂綋鎻忚堪錛?
    JDOM鐨勮緭鍑虹被XMLOutputter鏈変袱涓猳utput鎺ュ彛錛岄櫎浜嗛兘鍏鋒湁涓涓狣ocument鍙傛暟澶栵紝鍒嗗埆鎺ュ彈Writer鍜?OutputStream鍙傛暟銆?
    榪欑粰鎴戜滑涓涓敊瑙夛紝涓や釜鎺ュ彛鍙互浠繪剰浣跨敤銆?
    棣栧厛鎴戜滑鐢╫utput(doc,System.out)鏉ュ仛嫻嬭瘯錛屾鏃跺緱鍒頒貢鐮侊紝
      鐒跺悗鎴戜滑鏀逛負output(doc,new PrintWriter(System.out))鏉ユ祴璇曪紝杈撳嚭涓嶆槸涔辯爜錛?
      涔熷氨鏄鍦ㄦ帶鍒跺彴鐨勬椂鍊欎竴瀹氳鐢ㄤ竴涓猈riter鎺ュ彛鍖呰涓涓嬨?
     鐒跺悗鎴戜滑鐢╫utput(doc,new FileWriter(path))鏉ュ仛嫻嬭瘯錛岀粨鏋滃嵈寰楀埌涔辯爜錛?
      鐒跺悗鎴戜滑鏀逛負output(doc,new FileOutputStream(path))鏉ユ祴璇曪紝杈撳嚭涓嶆槸涔辯爜錛?
      涔熷氨鏄鍦ㄨ緭鍑烘枃浠剁殑鏃跺欎竴瀹氳鐢ㄤ竴涓狾utputStream鎺ュ彛鍖呰涓涓嬨?
     鐤簡鍚э紵鍛靛懙錛屽緢鎼炵瑧鏄惂銆傜粡榪囧埌JDOM鐨勬簮鐮佷腑璋冭瘯錛屽彂鐜版病鏈変換浣曢棶棰橈紝闂鍑哄湪浜咼DK閲岄潰銆?
JDK鍐呯殑瀵瑰簲鎺ュ彛澶勭悊錛?
1錛塒rintWriter綾繪湁鍙傛暟涓篛utputStream鐨勬瀯閫犳柟娉曪紝鍥犳鍙互浠嶴ystem.out鍖呰鍒癙rintWriter
2錛塅ileWriter綾繪病鏈夊弬鏁頒負OutputStream鐨勬瀯閫犳柟娉曪紝鍥犳涓嶈兘浠嶧ileOutputStream鍖呰鍒?FileWriter
3錛夊鏋淧rintWriter綾葷敤浜嗗弬鏁頒負Writer鐨勬瀯閫犳柟娉曪紙Writer瀹炵幇涓篎ileWriter錛夛紝鏈鍚庤緭鍑轟篃鏄貢鐮?
4錛夊鏋滅敤涓涓狥ileOutputStream鏉ュ寘瑁呬竴涓帶鍒跺彴杈撳嚭錛屼篃鏄貢鐮?
鍥犳錛屽浜嶫DK鍐呯殑鍚勭杈撳嚭浣撶郴錛屽悇縐岻nputStream銆丱utputStream銆乺eader鍜寃riter瑕佸厖鍒嗚璇嗭紝鍚﹀垯鏋佸鏄撳嚭鐜頒竴浜涙剰鎯充笉鍒扮殑闂銆?




abin 2012-08-15 09:34 鍙戣〃璇勮
]]>
JDOM 鐢熸垚鍜岃В鏋怷ML(浜?http://m.tkk7.com/stevenjohn/archive/2012/07/20/383613.htmlabinabinFri, 20 Jul 2012 09:37:00 GMThttp://m.tkk7.com/stevenjohn/archive/2012/07/20/383613.htmlhttp://m.tkk7.com/stevenjohn/comments/383613.htmlhttp://m.tkk7.com/stevenjohn/archive/2012/07/20/383613.html#Feedback0http://m.tkk7.com/stevenjohn/comments/commentRss/383613.htmlhttp://m.tkk7.com/stevenjohn/services/trackbacks/383613.html//JDOM xml鐨勭敓鎴?br />import java.io.ByteArrayOutputStream;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.output.XMLOutputter;


public class CreateJdom {
 public static String createXml(){
  Element root=new Element("cupMobiles");
  Document doc=new Document(root);
  
  Element cupMobile=new Element("cupMobile");
  cupMobile.setAttribute("application", "UPNoCard");
  cupMobile.setAttribute("version", "1.01");
  root.addContent(cupMobile);
  
  Element transaction=new Element("transaction");
  transaction.setAttribute("type","Purchase.PMReq");
  cupMobile.addContent(transaction);
  
  Element submitTime=new Element("submitTime");
  submitTime.setText("20111207111641");
  transaction.addContent(submitTime);
  
  Element order=new Element("order");
  order.setAttribute("id", "12347733");
  transaction.addContent(order);
  
  Element merchant=new Element("merchant");
  merchant.setAttribute("id","303290047228001");
  transaction.addContent(merchant);
  
  Element accountNumber1=new Element("accountNumber1");
  accountNumber1.setText("6224130665233518");
  transaction.addContent(accountNumber1);
  
  Element transSerialNumber=new Element("transSerialNumber");
  transSerialNumber.setText("201162");
  transaction.addContent(transSerialNumber);
  
  Element billAmount =new Element("billAmount");
  billAmount.setAttribute("currency","156");
  billAmount.setText("000000030231");
  transaction.addContent(billAmount);
  
  Element settleDate=new Element("settleDate");
  settleDate.setText("20111208");
  transaction.addContent(settleDate);
  
  ByteArrayOutputStream byteRsp=new ByteArrayOutputStream();
  XMLOutputter xmlOut=new XMLOutputter();
  try {
   xmlOut.output(doc, byteRsp);
  } catch (Exception e) {
   e.printStackTrace();
   System.out.println(e.getMessage());
  }
  return byteRsp.toString();
 }
 
 
 public static void main(String[] args) {
  
 }
}



//JDOM xml鐨勭敓鎴愮殑嫻嬭瘯浠g爜
import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class CreateJdomTest extends TestCase{
 @Before
 public void setUp(){}
 @After
 public void tearDown(){}
 @Test
 public void testCreateJdom(){
  String result=new CreateJdom().createXml();
  System.out.println(result);
 }
}






//JDOM xml鐨勮В鏋愪互鍙婅В鏋愮殑嫻嬭瘯浠g爜
import java.io.StringReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;
import org.xml.sax.InputSource;

public class ParseJdom {
 public static Map<String, String> parseXml(String xml) {
  Map<String, String> map = Collections
    .synchronizedMap(new HashMap<String, String>());
  StringReader reader = new StringReader(xml);
  InputSource source = new InputSource(reader);
  SAXBuilder sax = new SAXBuilder();
  try {
   Document doc = sax.build(source);
   Element root = doc.getRootElement();
//   map.put(root.getName(), root.getValue());
//   System.out.println("root=" + root.getName());
//   System.out.println("root,s value=" + root.getValue());
   
   Element cupMobile = null;
   cupMobile = root.getChild("cupMobile");
//   map.put(cupMobile.getName(), cupMobile.getValue());
   String application=cupMobile.getAttributeValue("application");
   map.put("application", application);
   String version=cupMobile.getAttributeValue("version");
   map.put("version", version);

   
   Element transaction = null;
   transaction = cupMobile.getChild("transaction");
//   map.put(transaction.getName(), transaction.getValue());
   String type=transaction.getAttributeValue("type");
   map.put("type", type);

   Element submitTime = null;
   submitTime = transaction.getChild("submitTime");
   map.put(submitTime.getName(), submitTime.getValue());
   
   Element order  = null;
   order = transaction.getChild("order");
//   map.put(order.getName(), order.getValue());
   String orderId=order.getAttributeValue("id");
   map.put("orderId", orderId);

   Element merchant  = null;
   merchant = transaction.getChild("merchant");
//   map.put(merchant.getName(), merchant.getValue());
   String merchantId=merchant.getAttributeValue("id");
   map.put("merchantId", merchantId);

   Element accountNumber1  = null;
   accountNumber1 = transaction.getChild("accountNumber1");
   map.put(accountNumber1.getName(), accountNumber1.getValue());
   
   Element transSerialNumber  = null;
   transSerialNumber = transaction.getChild("transSerialNumber");
   map.put(transSerialNumber.getName(), transSerialNumber.getValue());
   
   Element billAmount  = null;
   billAmount = transaction.getChild("billAmount");
   map.put(billAmount.getName(), billAmount.getValue());
   String currency=billAmount.getAttributeValue("currency");
   map.put("currency", currency);
   
   Element settleDate  = null;
   settleDate = transaction.getChild("settleDate");
   map.put(settleDate.getName(), settleDate.getValue());
   
   
   
  } catch (Exception e) {
   e.printStackTrace();
   System.out.println(e.getMessage());
  }
  return map;
 }

 public static void main(String[] args) {
  String xml = new CreateJdom().createXml();
  Map<String, String> map = new ParseJdom().parseXml(xml);
  Iterator it = map.entrySet().iterator();
  while (it.hasNext()) {
   Map.Entry<String, String> entry = (Map.Entry<String, String>) it
     .next();
   System.out.println("key=" + entry.getKey());
   System.out.println("Value=" + entry.getValue());
  }

 }
}


 



abin 2012-07-20 17:37 鍙戣〃璇勮
]]>
JDOM 鍒涘緩鍜岃В鏋怷ML(涓)http://m.tkk7.com/stevenjohn/archive/2012/07/19/383529.htmlabinabinThu, 19 Jul 2012 10:13:00 GMThttp://m.tkk7.com/stevenjohn/archive/2012/07/19/383529.htmlhttp://m.tkk7.com/stevenjohn/comments/383529.htmlhttp://m.tkk7.com/stevenjohn/archive/2012/07/19/383529.html#Feedback0http://m.tkk7.com/stevenjohn/comments/commentRss/383529.htmlhttp://m.tkk7.com/stevenjohn/services/trackbacks/383529.htmlpackage org.litsoft.air.unionpay;

import java.io.ByteArrayOutputStream;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.output.XMLOutputter;

public class CreateJdom {
 /**
  * 鐢熸垚鏀粯瀹濋渶瑕佺殑XML鏍煎紡錛岃嚜宸辨ā鎷熸祴璇曟敮浠樻帴鍙g殑寮傛榪斿洖緇撴灉
  * @return
  */
 public static String createXml(){
  Element root=new Element("notify");
  Document doc=new Document(root);
  Element trade_status=new Element("trade_status");
  trade_status.setText("TRADE_FINISHED");
  root.addContent(trade_status);
  
  Element total_fee=new Element("total_fee");
  total_fee.setText("0.90");
  root.addContent(total_fee);
  
  Element subject=new Element("subject");
  subject.setText("123465");
  root.addContent(subject);
  
  Element out_trade_no=new Element("out_trade_no");
  out_trade_no.setText("1118060201-7555");
  root.addContent(out_trade_no);
  
  Element notify_reg_time=new Element("notify_reg_time");
  notify_reg_time.setText("2010-11-1814:02:43.000");
  root.addContent(notify_reg_time);
  
  Element trade_no=new Element("trade_no");
  trade_no.setText("2010111800209965");
  root.addContent(trade_no);
  
  ByteArrayOutputStream byteRsp=new ByteArrayOutputStream();
  XMLOutputter xmlOut=new XMLOutputter();
  try {
   xmlOut.output(doc, byteRsp);
  } catch (Exception e) {
   e.printStackTrace();
   System.out.println(e.getMessage());
  }
  String temp=byteRsp.toString();
  String result=temp.substring(temp.indexOf(">")+1, temp.length());
  return result.trim();
//  return byteRsp.toString();
 }
 
 public static void main(String[] args) {
  CreateJdom jdom=new CreateJdom();
  String result=jdom.createXml();
  System.out.println(result);
 }

}











package org.litsoft.air.unionpay;

import java.io.StringReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;
import org.xml.sax.InputSource;

public class ParseJdom {
 /**
  * 瑙f瀽XMl閲岄潰鐨勬瘡涓瓧孌?br />  * @param xml
  * @return
  */
 public static Map<String,String> parseXml(String xml){
  Map<String,String> map=Collections.synchronizedMap(new HashMap<String,String>());
  StringReader reader=new StringReader(xml);
  InputSource source=new InputSource(reader);
  SAXBuilder sax=new SAXBuilder();
  try {
   Document doc=sax.build(source);
   Element root=doc.getRootElement();
   System.out.println("root,s name="+root.getName());
   System.out.println("root,s value="+root.getValue());
   List node=root.getChildren();
   Element element=null;
   for(int i=0;i<node.size();i++){
    element=(Element)node.get(i);
    map.put(element.getName(), element.getValue());
   }
  } catch (Exception e) {
   e.printStackTrace();
  }
  return map;
 }
 
 public static void main(String[] args) {
  String xmlHeader="<"+"?"+"xml"+" version="+"\"1.0\""+" encoding="+"\"UTF-8\""+"?"+">";
  CreateJdom jdom=new CreateJdom();
  String result=jdom.createXml();
  System.out.println("xmlHeader+result="+xmlHeader+result);
  Map<String,String> map=new ParseJdom().parseXml(xmlHeader+result);
  Iterator it=map.entrySet().iterator();
  while(it.hasNext()){
   Map.Entry<String, String> entry=(Map.Entry<String, String>)it.next();
   System.out.println(entry.getKey()+" , "+entry.getValue());
  }
  
 }
}



abin 2012-07-19 18:13 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 久久久久久久国产免费看| 亚洲AV综合色区无码一区爱AV| 51视频精品全部免费最新| 成人午夜影视全部免费看| 亚洲日韩看片无码电影| 18gay台湾男同亚洲男同| 在线a亚洲v天堂网2019无码| 日韩激情无码免费毛片| 青青草a免费线观a| 亚洲免费黄色网址| 性xxxx视频免费播放直播| 91精品全国免费观看青青| 麻豆安全免费网址入口| 亚洲av片在线观看| 亚洲乱码无人区卡1卡2卡3| 亚洲AV无码国产精品色| 亚洲图片校园春色| 亚洲美女大bbbbbbbbb| 久久久久亚洲Av无码专| 亚洲AV无码码潮喷在线观看| 亚洲精品成人无限看| 国产亚洲精AA在线观看SEE| 亚洲中文字幕无码一久久区| 国产亚洲自拍一区| 亚洲色精品aⅴ一区区三区| 在线观看国产区亚洲一区成人 | 亚洲一级黄色视频| 亚洲国产成人精品久久久国产成人一区二区三区综 | 全免费a级毛片免费看无码| 好吊妞788免费视频播放 | 亚洲精品V天堂中文字幕| 亚洲精品女同中文字幕| 精品韩国亚洲av无码不卡区| 美女被免费网站视频在线| 特黄aa级毛片免费视频播放| 人人爽人人爽人人片A免费| 亚洲免费日韩无码系列| a国产成人免费视频| 一区二区三区四区免费视频| 四虎在线免费视频| 午夜小视频免费观看|