Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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Îļþ²Ù×÷FileÀàºÍFilenameFilterµÄʹÓÃ

FileÀà
´´½¨Ä¿Â¼£¬ÓÃmkdirºÍmkdirsµÄº¯Êý
public boolean mkdir():´´½¨´Ë³éÏ󷾶ÃûÖ¸¶¨µÄĿ¼¡£
public boolean mkdirs():´´½¨´Ë³éÏ󷾶ÃûÖ¸¶¨µÄĿ¼£¬°üÀ¨ËùÓбØÐ赫²»´æÔڵĸ¸Ä¿Â¼¡£×¢Ò⣬´Ë²Ù×÷ʧ°ÜʱҲ¿ÉÄÜÒѾ­³É¹¦µØ´´½¨ÁËÒ»²¿·Ö±ØÐèµÄ¸¸Ä¿Â¼¡£
mkdirÀý×Ó£º
 File dir = new File("E:/mydir/");
if(!di ......

¼¸ÖÖ¶ÁÈ¡ÊôÐÔÎļþµÄ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»ñÈ¡ÇëÇó¿Í»§¶ËµÄÕæʵIPµØÖ·

 ÔÚJSPÀ»ñÈ¡¿Í»§¶ËµÄIPµØÖ·µÄ·½·¨ÊÇ£ºrequest.getRemoteAddr()£¬ÕâÖÖ·½·¨Ôڴ󲿷ÖÇé¿ö϶¼ÊÇÓÐЧµÄ¡£µ«ÊÇÔÚͨ¹ýÁËApache,SquidµÈ·´Ïò´úÀíÈí¼þ¾Í²»ÄÜ»ñÈ¡µ½¿Í»§¶ËµÄÕæʵIPµØÖ·ÁË¡£
Èç¹ûʹÓÃÁË·´Ïò´úÀíÈí¼þ£¬½«http://192.168.1.110:2046/ µÄURL·´Ïò´úÀíΪhttp://www.xxx.com/ µÄURLʱ£¬ÓÃrequest.getRemoteAddr()·½ ......

JAVAÏîÄ¿¼Ü¹¹¡úÎҵļû½â

ÔÚÍøÉÏÒ²¿´Á˺ܶණÎ÷£¬¹ØÓÚJAVAÈí¼þ¼Ü¹¹·½ÃæµÄ¶«Î÷£¬ÏÖÔÚ»¹ÕæÊǺÜÄÑÕÒµ½£¬²»¹ý£¬Èí¼þ¿ª·¢µÄ¼Ü¹¹»ù±¾ÊÇÏàͬµÄ¡£ËùÒÔ£¬ÎÒÔÚÍøÉϲéÕÒÁ˺ܶàÆäËûÓïÑÔ¹ØÓÚÈí¼þ¼Ü¹¹·½ÃæµÄÎÄÕ¡£ÔÙÕâÀïÒ²À´ËµËµ×Ô¼º¶ÔÈí¼þ¼Ü¹¹£¬ÌرðÊÇÔÚJAVAÏîÄ¿¼Ü¹¹·½ÃæµÄ¿´·¨¡£ËµµÃ²»Ò»¶¨¶Ô£¬µ«ÕâÒ²ÊÇÎÒ¼¸ÄêÀ´µÄ×ܽá°É¡£
1. ¾¡Á¿²»Òª¿¼ÂÇÏîÄ¿ÍâµÄÖØÓÃ
Ðí¶àÈË ......

javaÖйØÓÚÓÅÏȼ¶¶ÓÁеÄʵÏÖ




       
Õ⼸ÌìÒ»Ö±ÔÚ¸ã¹ØÓÚÓÅÏȼ¶¶ÓÁеÄʵÏÖ,ÒòΪҪ¿¼Âǵ½Ï̵߳ݲȫ,ËùÒÔPriorityQueue¾Í²»ÊÊÓÃÁË¡£Ò»¸ö·Ç³£¼òµ¥µÄʵÏÖ·½
·¨£¬ÄǾÍÊÇ°ÑÓÅÏȼ¶±È½ÏºÃµÄ²åÈëÒ»¸ö¶ÓÁУ¬ÓÅÏȼ¶µÍµÄ²åÈëÁíÒ»¸ö¶ÓÁУ¬È¡ÊýµÄʱºòÏÈÔÚÓÅÏȼ¶¸ßµÄ¶ÓÁÐÉÏÈ¡Êý¡£ÕâÓиöȱµã¾ÍÊÇÈç¹ûÓÅÏȼ¶±ðÔ½¶àµÄ»°£¬¶ÓÁ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ