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

java½âÎöxmlÎļþ

==========================================
xmlÎļþ
£¼?xml version="1.0" encoding="GB2312"?£¾
£¼RESULT£¾
£¼VALUE£¾
¡¡¡¡ £¼NO£¾A1234£¼/NO£¾
¡¡¡¡ £¼ADDR£¾ËÄ´¨Ê¡XXÏØXXÕòXX·X¶ÎXXºÅ£¼/ADDR£¾
£¼/VALUE£¾
£¼VALUE£¾
¡¡¡¡ £¼NO£¾B1234£¼/NO£¾
¡¡ ¡¡£¼ADDR£¾ËÄ´¨Ê¡XXÊÐXXÏçXX´åXX×飼/ADDR£¾
£¼/VALUE£¾
£¼/RESULT£¾
ÐèҪʲô°ü×Ô¼ºµ½ÍøÉÏÕÒÏ°ɣ¿
==========================================
1£©DOM£¨JAXP Crimson½âÎöÆ÷£©
DOMÊÇÓÃÓëƽ̨ºÍÓïÑÔÎ޹صķ½Ê½±íʾXMLÎĵµµÄ¹Ù·½W3C±ê×¼¡£DOMÊÇÒÔ²ã´Î½á¹¹×éÖ¯µÄ½Úµã»òÐÅϢƬ¶ÏµÄ¼¯ºÏ¡£Õâ¸ö²ã´Î½á¹¹ÔÊÐí¿ª·¢ÈËÔ±ÔÚÊ÷ÖÐÑ°ÕÒ
Ìض¨ÐÅÏ¢¡£·ÖÎö¸Ã½á¹¹Í¨³£ÐèÒª¼ÓÔØÕû¸öÎĵµºÍ¹¹Ôì²ã´Î½á¹¹£¬È»ºó²ÅÄÜ×öÈκι¤×÷¡£ÓÉÓÚËüÊÇ»ùÓÚÐÅÏ¢²ã´ÎµÄ£¬Òò¶øDOM±»ÈÏΪÊÇ»ùÓÚÊ÷»ò»ùÓÚ¶ÔÏóµÄ¡£DOM
ÒÔ¼°¹ãÒåµÄ»ùÓÚÊ÷µÄ´¦Àí¾ßÓм¸¸öÓŵ㡣Ê×ÏÈ£¬ÓÉÓÚÊ÷ÔÚÄÚ´æÖÐÊdz־õģ¬Òò´Ë¿ÉÒÔÐÞ¸ÄËüÒÔ±ãÓ¦ÓóÌÐòÄܶÔÊý¾ÝºÍ½á¹¹×÷³ö¸ü¸Ä¡£Ëü»¹¿ÉÒÔÔÚÈκÎʱºòÔÚÊ÷ÖÐÉÏÏÂ
µ¼º½£¬¶ø²»ÊÇÏñSAXÄÇÑùÊÇÒ»´ÎÐԵĴ¦Àí¡£DOMʹÓÃÆðÀ´Ò²Òª¼òµ¥µÃ¶à¡£
import java.io.*;
import java.util.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
public class MyXMLReader{
¡¡public static void main(String arge[]){
¡¡¡¡long lasting =System.currentTimeMillis();
¡¡¡¡try{
¡¡¡¡¡¡File f=new File("data_10k.xml");
¡¡¡¡¡¡DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
¡¡¡¡¡¡DocumentBuilder builder=factory.newDocumentBuilder();
¡¡¡¡¡¡Document doc = builder.parse(f);
¡¡¡¡¡¡NodeList nl = doc.getElementsByTagName("VALUE");
¡¡¡¡¡¡for (int i=0;i£¼nl.getLength();i++){
¡¡¡¡¡¡¡¡System.out.print("³µÅƺÅÂë:" + doc.getElementsByTagName("NO").item(i).getFirstChild().getNodeValue());
¡¡¡¡¡¡¡¡System.out.println("³µÖ÷µØÖ·:" + doc.getElementsByTagName("ADDR").item(i).getFirstChild().getNodeValue());
¡¡ ¡¡}
¡¡¡¡}catch(Exception e){
¡¡¡¡¡¡e.printStackTrace();
}
==========================================
2£©SAX
SAX´¦ÀíµÄÓŵã·Ç³£ÀàËÆÓÚÁ÷ýÌåµÄÓŵ㡣·ÖÎöÄܹ»Á¢¼´¿ªÊ¼£¬¶ø²»ÊǵȴýËùÓеÄÊý¾Ý±»´¦Àí¡£¶øÇÒ£¬ÓÉÓÚÓ¦ÓóÌÐ


Ïà¹ØÎĵµ£º

JAVAѧϰ֮·

 ¡¡ ¡¡¡¡
¡¡¡¡Èí¼þ¿ª·¢Ö®Â·ÊdzäÂú¾£¼¬ÓëÌôս֮·,Ò²ÊdzäÂúÏ£Íû֮·¡£JAVAѧϰҲÊÇÈç´Ë£¬Ã»Óнݾ¶¿É×ß¡£ÃÎÏëÏñ¡¶ÌìÁú°Ë²¿¡·ÖÐÐéÖñÒ»Ñù±»ÎÞÑÂ×Óõ®õ­¹à¶¥¶øÇáËÉ»ñµÃÒ»¼××Ó¹¦Á¦£¬ÊǺܲ»ÏÖʵµÄ¡£Ã¿ÌìÑöÌì´ó½Ð"ÌìÉñ°¡£¬Çë´Í¸øÎÒÒ»±¾¿û»¨±¦µä°É"£¬Êâ²»Öª¼´Ê¹Äã»ñµÃÁË¿û»¨±¦µä£¬³ýÁËÊÜ×Ô¹¬ÆäÉíÖ®¿àÍ⣬ÄãÒ²²»Ò»¶¨³ÉµÃÁË"¶«·½² ......

javaµ÷ÓÃnative2ascii.exe

 ±¾ÎÄÀ´×ÔCSDN²©¿Í£ºhttp://blog.csdn.net/xyk0830/archive/2007/11/06/1869638.aspx
ÃüÁîÐиñʽ£º
native2ascii.exe -[options] [inputfile [outputfile]]
ÆäÖУº
¡¡¡¡-[options]±íʾÃüÁ¹Ø£¬ÓÐÁ½¸öÑ¡Ïî¿É¹©Ñ¡Ôñ£º
¡¡¡¡¡¡¡¡-reverse£ºÓÃLatin-1»òUnicode±àÂë°ÑÎļþת»»³É±¾µØ±àÂë¸ñʽ
¡¡¡¡¡¡¡¡-encoding ......

¼¸ÖÖ¶ÁÈ¡ÊôÐÔÎļþµÄJAVAʵÏÖ·½Ê½

 
1.ʹÓÃjava.util.PropertiesÀàµÄload()·½·¨
InputStream in = lnew BufferedInputStream(new FileInputStream(name));
¡¡¡¡Properties p = new Properties();
¡¡¡¡p.load(in);
2.ʹÓÃjava.util.ResourceBundleÀàµÄgetBundle()·½·¨¡¡¡¡
ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault ......

javaÉú²úÕßÏû·ÑÕß

ÌâÄ¿£ºÇëÓöàÏß³ÌʵÏÖÒ»¸öÉú²úÕßÀàºÍÒ»¸öÏû·ÑÕßÀ࣬Éú²úÕßËæ»úÉú³É20¸ö×Ö·û£¬Ïû·ÑÕß½«×Ö·û´òÓ¡µ½¿ØÖÆ̨¡£
class SyncStack{ //ͬ²½¶ÑÕ»Àà
¡¡¡¡¡¡private int index = 0; //¶ÑÕ»Ö¸Õë³õʼֵΪ0
¡¡¡¡¡¡private char []buffer = new char[6]; //¶ÑÕ»ÓÐ6¸ö×Ö·ûµÄ¿Õ¼ä
¡¡¡¡¡¡public synchronized void push(char c){ //¼ÓÉ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ