JavaµÄXMLÎļþ²Ù×÷Ö®DOMÈëÃÅƪ £¨1£©
DOM³õ²½
DOMÊÇDocument Object ModelµÄËõд£¬¼´Îĵµ¶ÔÏóÄ£ÐÍ¡£Ç°Ãæ˵¹ý£¬XML½«Êý¾Ý×é֯Ϊһ¿ÅÊ÷£¬ËùÒÔDOM¾ÍÊǶÔÕâ¿ÅÊ÷µÄÒ»¸ö¶ÔÏóÃèÐð¡£Í¨Ë×µÄ˵£¬¾ÍÊÇͨ¹ý½âÎöXMLÎĵµ£¬ÎªXMLÎĵµÔÚÂß¼ÉϽ¨Á¢Ò»¸öÊ÷Ä£ÐÍ£¬Ê÷µÄ½ÚµãÊÇÒ»¸ö¸ö¶ÔÏó¡£ÎÒÃÇͨ¹ý´æÈ¡ÕâЩ¶ÔÏó¾ÍÄܹ»´æÈ¡XMLÎĵµµÄÄÚÈÝ¡£
ÏÂÃæÎÒÃÇÀ´¿´Ò»¸ö¼òµ¥µÄÀý×Ó£¬¿´¿´ÔÚDOMÖУ¬ÎÒÃÇÊÇÈçºÎÀ´²Ù×÷Ò»¸öXMLÎĵµµÄ¡£
ÕâÊÇÒ»¸öXMLÎĵµ£¬Ò²ÊÇÎÒÃÇÒª²Ù×÷µÄ¶ÔÏó£º
Good-bye serialization, hello Java!
ÏÂÃ棬ÎÒÃÇÐèÒª°ÑÕâ¸öÎĵµµÄÄÚÈݽâÎöµ½Ò»¸ö¸öµÄJava¶ÔÏóÖÐÈ¥¹©³ÌÐòʹÓã¬ÀûÓÃJAXP£¬ÎÒÃÇÖ»Ð輸ÐдúÂë¾ÍÄÜ×öµ½ÕâÒ»µã¡£Ê×ÏÈ£¬ÎÒÃÇÐèÒª½¨Á¢Ò»¸ö½âÎöÆ÷¹¤³§£¬ÒÔÀûÓÃÕâ¸ö¹¤³§À´»ñµÃÒ»¸ö¾ßÌåµÄ½âÎöÆ÷¶ÔÏó£º
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
ÎÒÃÇÔÚÕâÀïʹÓÃDocumentBuilderFacotryµÄÄ¿µÄÊÇΪÁË´´½¨Óë¾ßÌå½âÎöÆ÷Î޹صijÌÐò£¬µ±DocumentBuilderFactoryÀàµÄ¾²Ì¬·½·¨newInstance()±»µ÷ÓÃʱ£¬Ëü¸ù¾ÝÒ»¸öϵͳ±äÁ¿À´¾ö¶¨¾ßÌåʹÓÃÄÄÒ»¸ö½âÎöÆ÷¡£ÓÖÒòΪËùÓеĽâÎöÆ÷¶¼·þ´ÓÓÚJAXPËù¶¨ÒåµÄ½Ó¿Ú£¬ËùÒÔÎÞÂÛ¾ßÌåʹÓÃÄÄÒ»¸ö½âÎöÆ÷£¬´úÂ붼ÊÇÒ»ÑùµÄ¡£ËùÒÔµ±ÔÚ²»Í¬µÄ½âÎöÆ÷Ö®¼ä½øÐÐÇл»Ê±£¬Ö»ÐèÒª¸ü¸Äϵͳ±äÁ¿µÄÖµ£¬¶ø²»Óøü¸ÄÈκδúÂë¡£Õâ¾ÍÊǹ¤³§Ëù´øÀ´µÄºÃ´¦¡£Õâ¸ö¹¤³§Ä£Ê½µÄ¾ßÌåʵÏÖ£¬¿ÉÒԲο´ÏÂÃæµÄÀàͼ¡£
DocumentBuilder db = dbf.newDocumentBuilder();
µ±»ñµÃÒ»¸ö¹¤³§¶ÔÏóºó£¬Ê¹ÓÃËüµÄ¾²Ì¬·½·¨newDocumentBuilder()·½·¨¿ÉÒÔ»ñµÃÒ»¸öDocumentBuilder¶ÔÏó£¬Õâ¸ö¶ÔÏó´ú±íÁ˾ßÌåµÄDOM½âÎöÆ÷¡£µ«¾ßÌåÊÇÄÄÒ»ÖÖ½âÎöÆ÷£¬Î¢ÈíµÄ»òÕßIBMµÄ£¬¶ÔÓÚ³ÌÐò¶øÑÔ²¢²»ÖØÒª¡£
È»ºó£¬ÎÒÃǾͿÉÒÔÀûÓÃÕâ¸ö½âÎöÆ÷À´¶ÔXMLÎĵµ½øÐнâÎöÁË£º
Document doc = db.parse("c:/xml/message.xml");
DocumentBuilderµÄparse()·½·¨½ÓÊÜÒ»¸öXMLÎĵµÃû×÷ΪÊäÈë²ÎÊý£¬·µ»ØÒ»¸öDocument¶ÔÏó£¬Õâ¸öDocument¶ÔÏó¾Í´ú±íÁËÒ»¸öXMLÎĵµµÄÊ÷Ä£ÐÍ¡£ÒÔºóËùÓеĶÔXMLÎĵµµÄ²Ù×÷£¬¶¼Óë½âÎöÆ÷Î޹أ¬Ö±½ÓÔÚÕâ¸öDocument¶ÔÏóÉϽøÐвÙ×÷¾Í¿ÉÒÔÁË¡£¶ø¾ßÌå¶ÔDocument²Ù×÷µÄ·½·¨£¬¾ÍÊÇÓÉDOMËù¶¨ÒåµÄÁË¡£
JaxpÖ§³ÖW3CËùÍƼöµÄDOM 2¡£Èç¹ûÄã¶ÔDOMºÜÊìϤ£¬ÄÇôÏÂÃæµÄÄÚÈݾͺܼòµ¥ÁË£ºÖ»ÐèÒª°´ÕÕDOMµÄ¹æ·¶À´½øÐз½·¨µ÷ÓþͿÉÒÔ¡£µ±È»£¬Èç¹ûÄã¶ÔDOM²»Çå³þ£¬Ò²²»ÓÃ׿±£¬ºóÃæÎÒÃÇ»áÓÐÏêϸµÄ½éÉÜ¡£ÔÚÕâ¶ù£¬ÄãËùÒªÖªµÀ²¢ÀμǵÄÊÇ£ºDOMÊÇÓÃÀ´ÃèÐðXMLÎĵµÖеÄÊý¾ÝµÄÄ£ÐÍ£¬ÒýÈëDOMµÄÈ«²¿ÔÒò¾ÍÊÇΪÁËÓÃÕâ¸öÄ£ÐÍÀ´²Ù×÷XMLÎĵµµÄÖеÄÊý¾
Ïà¹ØÎĵµ£º
1.ÄãÐèÒª¾«Í¨ÃæÏò¶ÔÏó·ÖÎöÓëÉè¼Æ(OOA/OOD)¡¢É漰ģʽ(GOF£¬J2EEDP)ÒÔ¼°×ÛºÏģʽ¡£ÄãÓ¦¸ÃÊ®·ÖÁ˽âUML£¬ÓÈÆäÊÇclass£¬object£¬interactionÒÔ¼°statediagrams¡£
¡¡¡¡2.ÄãÐèҪѧϰJAVAÓïÑԵĻù´¡ÖªÊ¶ÒÔ¼°ËüµÄºËÐÄÀà¿â(collections£¬serialization£¬streams£¬networking£¬ multithreading ......
Èô·¾¶Öдø¿Õ¸ñ£¬Ôò
1. uri.getpath();·µ»ØµÄ·¾¶ÖеĿոñÈÔÒÔ“¿Õ¸ñ”µÄÐÎʽ³öÏÖ£¬Èç/F:/MyEclipse Workspace/project/bin/...
³ý´ËÖ®Í⣬URL·µ»ØµÄÒ»Çз¾¶ÖеĿոñ¶¼ÒÔ“%20”µÄÐÎʽ³öÏÖ£¬uri.toString()Ò²ÒÔ“%20”µÄÐÎʽ³öÏÖ¡£
2. new File(String filePath);½ÓÊÜÕýÈ·URI¸ñʽµÄ²ÎÊýº ......
±àÕß°´£º¶ÔJavaÉçÇøÀ´Ëµ,2009ÄêÊÇÒ»¸ö¶àÊÂÖ®Ä꣺OracleµÄÊÕ¹º´øÀ´Ï£Íûµ«¸ü¶àµÄÊǵ£ÓÇ£»¶ÔJava7µÄ½¹¼±µÈ´ý£»¶ÔÊÇ·ñÐèÒª±Õ°üµÄ³Ö
ÐøÕùÒ飻ÆäËûÊÕ¹º¶Ô¿ªÔ´ÉçÇøµÄÓ°Ïì±¾ÎÄÔ×÷ÕßJames SugrueÁªºÏJavaÉçÇøµÄÆäËûÈýλºËÐÄ¿ª·¢Õ߶Ô2009ÄêµÄJava½øÐÐÁËÅ̵㡣
James SugrueÊÇJavaLobbyºÍEclipseZoneµÄ±à¼£¬Ò»Î»Eclipse¿ª·¢Õߣ¬Jav ......
µ±È»£¬Ê×ÏÈÒª°²×°ÓÐJDK(Ò»°ãÊÇJDK1.5.X)¡£È»ºó°²×°MySQL£¬ÕâЩ¶¼±È½Ï¼òµ¥£¬¾ßÌå¹ý³Ì¾Í²»ËµÁË¡£ÅäÖúÃÕâÁ½¸ö
»·¾³ºó£¬ÏÂÔØJDBCÇý¶¯mysql-connector-java-5.1.5.zip£¨http://www.ntu-w.lkams.kernel.org/pub/MySQL/Downloads/Connector-J/mysql-connector-java-5.1.5.zip£©¡£È»ºó½«Æä½âѹËõµ½ÈÎһĿ¼¡£ÎÒÊǽâѹµ½DÅÌ£¬È»ºó½ ......
VectorÀàÔÚJava±à³ÌÖеÄÓ¦ÓÃ
Vector Àà Ìá ¹© ÁË Êµ ÏÖ ¿É Ôö ³¤ Êý ×é µÄ ¹¦ ÄÜ£¬ Ëæ ×Å ¸ü ¶à Ôª ËØ ¼Ó Èë Æä ÖУ¬
Êý ×é ±ä µÄ ¸ü ´ó¡£ ÔÚ É¾ ³ý Ò» Щ Ôª ËØ Ö® ºó£¬ Êý ×é ±ä С¡£
Vector ÓÐ Èý ¸ö ¹¹ Ôì º¯ Êý£¬
public Vector(int initialCapacity,int capacityIncrement)
public Vector(int initialCapacity) ......