JAVA½âÎöXMLµÄËÄÖÖ·½·¨±È½Ï
XMLÏÖÔÚÒѾ³ÉΪһÖÖͨÓõÄÊý¾Ý½»»»¸ñʽ,ËüµÄƽ̨ÎÞ¹ØÐÔ,ÓïÑÔÎÞ¹ØÐÔ,ϵͳÎÞ¹ØÐÔ,¸øÊý¾Ý¼¯³ÉÓë½»»¥´øÀ´Á˼«´óµÄ·½±ã¡£¶ÔÓÚXML±¾ÉíµÄÓ﷨֪ʶÓë¼¼Êõϸ½Ú,ÐèÒªÔĶÁÏà¹ØµÄ¼¼ÊõÎÄÏ×,ÕâÀïÃæ°üÀ¨µÄÄÚÈÝÓÐDOM(Document Object Model),DTD(Document Type Definition),SAX(Simple API for XML),XSD(Xml Schema Definition),XSLT(Extensible Stylesheet Language Transformations),¾ßÌå¿É²ÎÔÄw3c¹Ù·½ÍøÕ¾Îĵµhttp://www.w3.org»ñÈ¡¸ü¶àÐÅÏ¢¡£
XMLÔÚ²»Í¬µÄÓïÑÔÀï½âÎö·½Ê½¶¼ÊÇÒ»ÑùµÄ,Ö»²»¹ýʵÏÖµÄÓï·¨²»Í¬¶øÒÑ¡£»ù±¾µÄ½âÎö·½Ê½ÓÐÁ½ÖÖ,Ò»ÖÖ½ÐSAX£¬ÁíÒ»ÖÖ½ÐDOM¡£SAXÊÇ»ùÓÚʼþÁ÷µÄ½âÎö,DOMÊÇ»ùÓÚXMLÎĵµÊ÷½á¹¹µÄ½âÎö¡£¼ÙÉèÎÒÃÇXMLµÄÄÚÈݺͽṹÈçÏÂ:
<?xml version=”1.0″ encoding=”UTF-8″?> <employees>
<employee>
<name>ddviplinux</name>
<sex>m</sex>
<age>30</age>
</employee>
</employees>
±¾ÎÄʹÓÃJAVAÓïÑÔÀ´ÊµÏÖDOMÓëSAXµÄXMLÎĵµÉú³ÉÓë½âÎö¡£
Ê×Ïȶ¨ÒåÒ»¸ö²Ù×÷XMLÎĵµµÄ½Ó¿ÚXmlDocument Ëü¶¨ÒåÁËXMLÎĵµµÄ½¨Á¢Óë½âÎöµÄ½Ó¿Ú¡£
package com.alisoft.facepay.framework.bean;
/**
*
* @author hongliang.dinghl
* ¶¨ÒåXMLÎĵµ½¨Á¢Óë½âÎöµÄ½Ó¿Ú
*/
public interface XmlDocument {
/**
* ½¨Á¢XMLÎĵµ
* @param fileName Îļþȫ·¾¶Ãû³Æ
*/
public void createXml(String fileName);
/**
* ½âÎöXMLÎĵµ
* @param fileName Îļþȫ·¾¶Ãû³Æ
*/
public void parserXml(String fileName);
}
1. DOMÉú³ÉºÍ½âÎöXMLÎĵµ
Ϊ XML ÎĵµµÄÒѽâÎö°æ±¾¶¨ÒåÁËÒ»×é½Ó¿Ú¡£½âÎöÆ÷¶ÁÈëÕû¸öÎĵµ£¬È»ºó¹¹½¨Ò»¸öפÁôÄÚ´æµÄÊ÷½á¹¹£¬È»ºó´úÂë¾Í¿ÉÒÔʹÓà DOM ½Ó¿ÚÀ´²Ù×÷Õâ¸öÊ÷½á¹¹¡£Óŵ㣺Õû¸öÎĵµÊ÷ÔÚÄÚ´æÖУ¬±ãÓÚ²Ù×÷£»Ö§³Öɾ³ý¡¢Ð޸ġ¢ÖØÐÂÅÅÁеȶàÖÖ¹¦ÄÜ£»È±µã£º½«Õû¸öÎĵµµ÷ÈëÄڴ棨°üÀ¨ÎÞÓõĽڵ㣩£¬ÀË·Ñʱ¼äºÍ¿Õ¼ä£»Ê¹Óó¡ºÏ£ºÒ»µ©½âÎöÁËÎĵµ»¹Ðè¶à´Î·ÃÎÊÕâЩÊý¾Ý£»Ó²¼þ×ÊÔ´³ä×㣨ÄÚ´æ¡¢CPU£©¡£
package com.alisoft.facepay.framework.bean;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
impor
Ïà¹ØÎĵµ£º
public static void main(String args[]) {
Comparator cmp = (RuleBasedCollator)java.text.Collator.getInstance(java.util.Locale.CHINA);
String[] array = {"ÕÅÈý", "ÀîËÄ", "ÍõÎå"};
Arrays.sort(array, cmp);
for(String str : array){
System.out.println(str);
}
} ......
¹ÖÒìÖ®Ò»£º
connect(SocketAddress endpoint):Õâ¸ö·½·¨£¬³¢ÊÔÁ¬½Óserver¶Ë£¬Èç¹ûÁ¬½Ó²»ÉÏ£¬¾ÍÅ׳öIOExceptionÒì³£¡£Èç¹ûÁ¬½Ó³É¹¦ÁË£¬¾Í¼ÌÐøÖ´ÐÐÏÂÒ»²½µÄ´úÂë¡£
¹ÖÒìÖ®¶þ£º
boolean isConnected() :Õâ¸ö·½·¨µÄ½á¹û½ö½ö´ú±íÕâ¸ösocketÔø¾³É¹¦Á¬½Óµ½ÁËserver£¬µ«²¢²»±íʾÏÖÔÚÕâ¸öʱ¿ÌËüºÍserverÈÔ±£³ÖÁ¬½Ó״̬¡£
ÓÐ ......
Ò»£¬JavaÓïÑÔÖеĶÔÏóÒýÓÃ
C++ÖÐÖ¸ÕëºÍÒýÓüæÓУ¬¶øJavaÖÐûÓÐÖ¸ÕëµÄ¸ÅÄÍêÈ«ÓÃÒýÓÃÌæ´ú¡£ÈçC++ÖÐÒ»Ñù£¬ÒýÓÃÊÇÎÒÃǸø±äÁ¿µÄÒ»¸ö“±ðÃû”£¬Ò»¸ö±äÁ¿¿ÉÒÔÓжà¸ö“±ðÃû”¡£ÒýÓõÄÖµÊÇÒ»¸öÄÚ´æµØÖ·£¬ÔÚ¶ÔÏóµÄÒýÓñ»¶¨Òåʱ£¬È磺
String s; //´ËʱsֵΪ¿Õ£¬ÏµÍ³²¢Ã»ÓÐΪsËùÖ¸µÄ¶ÔÏó·ÖÅäÄÚ´æ
s = ......
µ±³ÌÐòµÄij¸öÄ£¿é±»µ÷ÓõÄʱ¿Ì²»È·¶¨£¬¾ÍÀàËÆÓڵȴýij¸öʼþµÄ·¢Éú¡£Õâʱ£¬¿ÉÒÔ¶¨Òå×Ô¼ºµÄʼþ½øÐÐÏàÓ¦µÄ´¦Àí¡£±ÈÈ磬µÈ´ýÓû§µÄÒ»´ÎÊäÈëµÈ¡£JavaµÄʼþÄ£ÐÍÒÀÀµÓÚίÍУ¬Í¨¹ý»Øµ÷·½·¨½øÐÐÏàÓ¦µÄʼþ´¦Àí¡£ÔÚʼþÔ´ÖУ¬»áÓÐfireXXXEvent()¾ÍÊǼ¤»îÏàÓ¦µÄʼþ£¬ÆäÖлá±éÀúʼþÔ´µÄ¼àÌýÆ ......
ÔںܶàJavaÓ¦ÓÃÖÐÐèÒªÔÚ³ÌÐòÖе÷ÓÃJava±àÒëÆ÷À´±àÒëºÍÔËÐС£µ«ÔÚÔçÆڵİ汾ÖУ¨Java SE5¼°ÒÔÇ°°æ±¾£©ÖÐÖ»ÄÜͨ¹ýtools.jarÖеÄcom.sun.tools.javac°üÀ´µ÷ÓÃJava±àÒëÆ÷£¬µ«ÓÉÓÚtools.jar²»ÊDZê×¼µÄJava¿â£¬ÔÚʹÓÃʱ±ØÐëÒªÉèÖÃÕâ¸öjarµÄ·¾¶¡£¶øÔÚJava SE6ÖÐΪÎÒÃÇÌṩÁ˱ê×¼µÄ°üÀ´²Ù×÷Java±àÒëÆ÷£¬Õâ¾ÍÊÇjavax.tools°ü¡£Ê¹ÓÃÕ ......