Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

[±¸·Ý]javaÖÐXML½âÎöÀûÆ÷ dom4jµÄʹÓüò½é


ҪʹÓÃdom4j¶ÁдXMLÎĵµ,ÐèÒªÏÈÏÂÔØdom4j°ü,dom4j¹Ù·½ÍøÕ¾ÔÚ http://www.dom4j.org/
Ä¿Ç°×îÐÂdom4j°üÏÂÔصØÖ·: http://nchc.dl.sourceforge.net/sourceforge/dom4j/dom4j-1.6.1.zip
½â¿ªºóÓÐÁ½¸ö°ü,½ö²Ù×÷XMLÎĵµµÄ»°°Ñdom4j-1.6.1.jar¼ÓÈ빤³Ì¾Í¿ÉÒÔÁË,Èç¹ûÐèҪʹÓÃXPathµÄ»°»¹ÐèÒª¼ÓÈë°üjaxen-1.1-beta-7.jar.
ÒÔÏÂÊÇÏà¹Ø²Ù×÷:
Ò»¡¢Document¶ÔÏóÏà¹Ø
1.¶ÁÈ¡XMLÎļþ,»ñµÃdocument¶ÔÏó.
            SAXReader reader = new SAXReader();
            Document document = reader.read(new File("input.xml"));
2.½âÎöXMLÐÎʽµÄÎı¾,µÃµ½document¶ÔÏó.
            String text = "<members></members>";
            Document document = DocumentHelper.parseText(text);
3.Ö÷¶¯´´½¨document¶ÔÏó.
            Document document = DocumentHelper.createDocument();
            Element root = document.addElement("members");// ´´½¨¸ù½Úµã
¶þ¡¢½ÚµãÏà¹Ø
1.»ñÈ¡ÎĵµµÄ¸ù½Úµã.
Element rootElm = document.getRootElement();
2.È¡µÃij½ÚµãµÄµ¥¸ö×Ó½Úµã.
Element memberElm=root.element("member");// "member"ÊǽڵãÃû
3.È¡µÃ½ÚµãµÄÎÄ×Ö
String text=memberElm.getText();
Ò²¿ÉÒÔÓÃ:
String text=root.elementText("name");Õâ¸öÊÇÈ¡µÃ¸ù½ÚµãϵÄname×Ö½ÚµãµÄÎÄ×Ö.
4.È¡µÃij½ÚµãÏÂÃûΪ"member"µÄËùÓÐ×ֽڵ㲢½øÐбéÀú.
List nodes = rootElm.elements("member");
for (Iterator it = nodes.iterator(); it.hasNext();) {
   Element elm = (Element) it.next();
   // do something
}
5.¶Ôij½ÚµãϵÄËùÓÐ×Ó½Úµã½øÐбéÀú.
            for(Iterator it=root.elementIterator();it.hasNext();){
                Element element = (Element) it.next();
    &n


Ïà¹ØÎĵµ£º

jaxpÏÂÓÃDOM½øÐÐxmlÎĵµ½âÎö

jaxpÊÇsun¹«Ë¾µÄ½âÎöxmlÎĵµµÄapi,ËûÖ§³ÖÓÃdomºÍsaxÁ½ÖÖ·½·¨½âÎöÒ»¸öxmlÎĵµ.
dom·½·¨ÊǽâÎöÒýÇ潫Õû¸öxmlÎĵµ×°Ôص½ÄÚ´æÖÐ×÷Ϊһ¸ödocument¶ÔÏó,dom·½·¨µÃµ½Ò»¸ö¶ÔÏó¾ÍÖªµÀËùÓеĽڵã
Ôöɾ¸Ä²éºÜ·½±ã,ȱµãÊÇҪװÔØÕû¸öxmlÎĵµ,Èç¹ûxmlÎĵµºÜ´ó,ЧÂʾͱȽϵÍ
sax·½·¨ÊDzÉÓÃʼþ×÷ΪÇý¶¯µÄ,Óöµ½Ò»¸ö±êÇ©ÊÇÒ»¸öʼþ,¶Áµ½±ê ......

javaÖÐÊý×éÓëListÏ໥ת»»µÄ·½·¨

1.Listת»»³ÉΪÊý×é¡££¨ÕâÀïµÄListÊÇʵÌåÊÇArrayList)
¡¡¡¡µ÷ÓÃArrayListµÄtoArray·½·¨¡£
¡¡¡¡toArray
¡¡¡¡public <T> T[] toArray(T[] a)·µ»ØÒ»¸ö°´ÕÕÕýÈ·µÄ˳Ðò°üº¬´ËÁбíÖÐËùÓÐÔªËصÄÊý×飻·µ»ØÊý×éµÄÔËÐÐʱÀàÐ;ÍÊÇÖ¸¶¨Êý×éµÄÔËÐÐʱÀàÐÍ¡£Èç¹ûÁбíÄÜ·ÅÈëÖ¸¶¨µÄÊý×飬Ôò·µ»Ø·ÅÈë´ËÁбíÔªËصÄÊý×é¡£·ñÔò£¬½«¸ù¾ ......

javaÏß³Ì

Ï̵߳Ĵ´½¨ºÍÆô¶¯
JavaÓïÑÔÒѾ­ÄÚÖÃÁ˶àÏß³ÌÖ§³Ö£¬ËùÓÐʵÏÖRunnable½Ó¿ÚµÄÀ඼¿É±»Æô¶¯Ò»¸öÐÂỊ̈߳¬ÐÂÏ̻߳áÖ´ÐиÃʵÀýµÄrun()·½·¨£¬µ±run()·½·¨Ö´ÐÐÍê±Ïºó£¬Ï߳̾ͽáÊøÁË¡£Ò»µ©Ò»¸öÏß³ÌÖ´ÐÐÍê±Ï£¬Õâ¸öʵÀý¾Í²»ÄÜÔÙÖØÐÂÆô¶¯£¬Ö»ÄÜÖØÐÂÉú³ÉÒ»¸öÐÂʵÀý£¬ÔÙÆô¶¯Ò»¸öÐÂÏ̡߳£
ThreadÀàÊÇʵÏÖÁËRunnable½Ó¿ÚµÄÒ»¸öʵÀý£¬Ëü´ú±í ......

JAVA·½·¨µ÷ÓÃЧÂʲî±ð

¡¡¡¡×î½üÐèÒª×öһЩJAVAµ×²ã²Ù×÷£¬ÎªÁ˾¡¿ÉÄÜÌá¸ßЧÂÊ×öÁËÈçϲâÊÔ¡£
¡¡¡¡ÔÚͬһ¸öÀàÖн¨Á¢ÆÕͨµÄPUBLIC·½·¨ºÍPUBLIC STATIC ·½·¨Á½ÖÖ£¬²¢Ê¹ÓÃJUnit½øÐжà´ÎÑ­»·¡£×îÖÕÖ¤Ã÷ʹÓöÔÏóµÄ·½Ê½µ÷ÓÃЧÂʸߡ£
¡¡¡¡ÉϽá¹û¡£
Æðʼʱ¼äFri Mar 05 10:15:37 CST 2010½áÊøʱ¼äFri Mar 05 10:15:38 CST 2010ʱ¼ä¼ä¸ô891
Æðʼʱ¼äFri ......

How to use Java as NT SERVICE


 service = new
 Service();  
        thread=new
 Thread(service);  
        try
  
        {  
   ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ