西西軟件園多重安全檢測(cè)下載網(wǎng)站、值得信賴的軟件下載站!
西西首頁 電腦軟件 安卓軟件 電腦游戲 安卓游戲 排行榜 專題合集

jdom jar

  • jdom jar
  • 軟件大小:142KB
  • 更新時(shí)間:2014-06-17 15:11
  • 軟件語言:中文
  • 軟件廠商:
  • 軟件類別:國產(chǎn)軟件 / 免費(fèi)軟件 / 編程輔助
  • 軟件等級(jí):4級(jí)
  • 應(yīng)用平臺(tái):WinAll, Win7
  • 官方網(wǎng)站:http://www.innovatechautomation.com
  • 應(yīng)用備案:
好評(píng):50%
壞評(píng):50%

軟件介紹

不用是你的損失!這么好用的包

本Jive(Jdon版)可在Jbuilder 7直接打開。

建議你用Jbuilder7打開后,編輯相應(yīng)設(shè)置(JDK1.4)

本軟件在linux+jdk1.4+tomcat 4以上環(huán)境運(yùn)行正常,中文顯示正常。

用法:

依賴于jar包: dom4j.jar 和 jaxen-1.1.1.jar 
Xml代碼  
1. <?xml version="1.0" encoding="UTF-8"?>  
2. <list>  
3. <index>D:\\index\\IndexDB</index>  
4. </list>  

Java代碼  
1. package com.wlh.dom4j.test;   
2.   
3. import org.dom4j.Document;   
4. import org.dom4j.DocumentException;   
5. import org.dom4j.Node;   
6. import org.dom4j.io.SAXReader;   
7.   
8. public class TestReader {   
9.     public static void main(String args[]){   
10.         String filePath="index.xml";   
11.         try {   
12.             //如果配置文件是在Src下,則采用如下方式得到Document   
13.             Document document=new SAXReader().read(Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath));   
14.             //如果配置文件是在本地文件系統(tǒng),則采用如下方式得到Document         
15.             //Document document=new SAXReader().read("D:\\index.xml");   
16.             if (document == null) {      
17.                 System.out.println(filePath+"沒找到");      
18.             }else{     
19.             Node node=document.selectSingleNode("//list/index");   
20.             String indexfile=node.getText();   
21.             System.out.println(indexfile);   
22.            }   
23.             } catch (DocumentException e) {   
24.             e.printStackTrace();   
25.                
26.         }      
27.     }   
28. }  

jdom讀取xml文件: 

依賴于jar包: jdom.jar 
得到URL的方式:Thread.currentThread().getContextClassLoader().getResource(filePath) 
Java代碼  
1. package com.wlh.dom4j.test;   
2.   
3. import java.io.IOException;   
4. import java.util.List;   
5.   
6. import org.jdom.Document;   
7. import org.jdom.Element;   
8. import org.jdom.JDOMException;   
9. import org.jdom.input.SAXBuilder;   
10.   
11. public class TestJdomReader {   
12.     public static void main(String args[]) {   
13.         String filePath = "zxt_index.xml";   
14.         String indexPath="";   
15.         SAXBuilder builder = new SAXBuilder(false);   
16.         try {   
17.             Document doc = builder.build(Thread.currentThread().getContextClassLoader().getResource(filePath));   
18.             Element books = doc.getRootElement();   
19.              Element rootElement= books.getChild("list");   
20.              Element index=rootElement.getChild("index");   
21.              indexPath=index.getText();   
22.              System.out.println(indexPath);   
23.         } catch (JDOMException e) {   
24.             e.printStackTrace();   
25.         } catch (IOException e) {   
26.             e.printStackTrace();   
27.         }   
28.   
29.     }   
30. }  

軟件標(biāo)簽: jar

其他版本下載

最新評(píng)論查看所有(1)條評(píng)論 >

第 1 樓 美國CZ88.NET 網(wǎng)友 客人 2016/1/8 13:15:10
挺好用的,多謝了

支持( 0 ) 蓋樓(回復(fù))

發(fā)表評(píng)論

昵稱:
表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
查看所有(1)條評(píng)論 > 字?jǐn)?shù): 0/500

TOP
軟件下載