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

Java HTML ParserÓ¦ÓÃ

×î½üÒòΪÏîÄ¿ÐèÒª£¬Ñо¿ÁËjava html parserÀà¿âµÄÓ¦Ó᣼ǼÏÂʹÓÃÒªµã£º
Ö÷ÒªµÄÀà˵Ã÷£º
1¡¢ParserÀà
½âÎöÆ÷Ö÷À࣬¸ºÔðÔØÈëHTML´úÂë²¢½âÎö¡£
2¡¢Node½Ó¿Ú
ÓÃÀ´±íÕ÷ÔÚ½âÎö¹ý³ÌÖÐʹÓõÄÓï·¨µ¥Ôª¡£Ê¾ÀýÈç϶Îhtml´úÂ룺
<span> ----Tag node
text ----Text Node
</span>
Îı¾ºÍ±êÇ©¶¼ÊǶÀÁ¢µÄnodeÔªËØ¡£textÎı¾ÊDZêÇ©spanµÄchild node
3¡¢NodeFilter
±êÇ©¹ýÂËÆ÷½Ó¿Ú£¬ÓÃÀ´ÔÚparser»òNodeListÖйýÂ˳öÐèÒªµÄijһÀànode¡£
4¡¢NodeList
Êý¾Ý½á¹¹£¬±íʾNodeµÄ¼¯ºÏ
ÐèÒªÌرð×¢ÒâµÄµØ·½£º
ParserºÍNodeList¶¼ÓÐÒ»¸öÃûΪextractAllNodesThatMatch(NodeFilter filter)µÄ·½·¨ÓÃÀ´¹ýÂ˳ö·ûºÏij¸öÌõ¼þµÄnode£¬µ«ÊÇÆäÄÚ²¿µÄʵÏÖ»úÖƲ»Í¬¡£
ParserÊÇÔÚ½âÎöÆ÷µÄ¹¦ÄÜ»ù´¡ÉÏʹÓÃIterorʵÏÖ¡£Ã¿´Îµ÷Óø÷½·¨ºóÐèÒªÖ´ÐÐreset·½·¨£¬·ñÔò»áÓ°ÏìÏÂÒ»´Îµ÷ÓõĽá¹û¡£
¶øNodeListÊÇÔÚÄÚ²¿µÄÊý×éÉϽøÐÐÑ­»·Åжϣ¬Òò´Ë¸÷´Îµ÷ÓÃÖ®¼ä²»»á»¥ÏàÓ°Ï죬ЧÂÊÒ²±ÈParserµÄ¸ß£¬ÍÁ½¨Ê¹Óá£
´úÂëʾÀý£º
ʵÏÖgetElementByID¹¦ÄÜ
<code>
public class NodeIDFilter implements NodeFilter {
 private String id;
 public NodeIDFilter(String id)
 {
 this.id=id;
 }
 public boolean accept(Node node) {
 if(node instanceof Tag)
 {
 if(!((Tag)node).isEndTag())
 {
 String s=((Tag)node).getAttribute("id");
 if(s!=null)
 return s.equals(this.id);
 }
 }
 return false;
 // throw new UnsupportedOperationException("Not supported yet.");
 }
}
public class MHTMLParser
{
....
protected Node getElementById(String id) throws ParserException
 {
 //this.myparser.reset();
 if(this.mNodeList==null||this.mNodeList.size()==0) return null;
 NodeIDFilter nodef = new NodeIDFilter(id);
 NodeList nl = this.mNodeList.extractAllNodesThatMatch(nodef,true);
 //
 if (nl.size() != 0)
 {
 return nl.elementAt(0);
 }
 return null;
 }
 
}
</code>


Ïà¹ØÎĵµ£º

javaÖжѣ¨heap)ºÍ¶ÑÕ»£¨stack)ÓÐʲôÇø±ð

//ת×Ôhttp://pterodactyl.javaeye.com/blog/345892
stack ºÍ heep ¶¼ÊÇÄÚ´æµÄÒ»²¿·Ö
stack ¿Õ¼äС£¬ËٶȱȽϿ죬 ÓÃÀ´·Å¶ÔÏóµÄÒýÓÃ
heep ´ó£¬Ò»°ãËùÓд´½¨µÄ¶ÔÏ󶼷ÅÔÚÕâÀï¡£
Õ»(stack):ÊÇÒ»¸öÏȽøºó³öµÄÊý¾Ý½á¹¹,ͨ³£ÓÃÓÚ±£´æ·½·¨(º¯Êý)ÖеIJÎÊý,¾Ö²¿±äÁ¿.
ÔÚjavaÖÐ,ËùÓлù±¾ÀàÐͺÍÒýÓÃÀàÐͶ¼ÔÚÕ»Öд洢.Õ»ÖÐÊý¾ÝµÄÉ ......

javaÊ÷Ðνṹ Ëã·¨

×î½ü¿´µ½Ò»¸öÓÐÒâ˼µÄÊ÷Ðνṹ£¬ÎªÃ¿¸ö½ÚµãÌí¼ÓÁËlft
ºÍ
rgt
Á½¸öÊôÐÔ¡£ÕâÑù²éÕҸýڵãµÄ×ӽڵ㡢
²éÕҸýڵãËùÓи¸½Úµã£¬¾Í²»ÓÃÈ¥µÝ¹é²éѯ£¬Ö»ÐèÒªÓÃ
between
¡¢
and
Óï¾ä¾Í¿ÉÒÔʵÏÖ¡£ÏÂÃæÒÔ´´½¨Ò»¸öÀ¸Ä¿Ê÷ΪÀý£¬ÒÔÏÂÊÇÎÒµÄÀí½â¡£
¡¡¡¡Ò»°ãÀ´½²£¬ÎÒÃÇ´´½¨À¸Ä¿Ê÷µÄʱºò£¬´ó¶àÖ»ÐèÒªÒ»¸öÍâ¼üparentid
À´Çø·Ö¸Ã½Úµã ......

Developing Games in Java£¨²¿·Ö£©

   Ô­ÎÄÀ´×ÔÓÚ¡¶Developing Games in Java¡·£¬×÷ÕߣºDavid Brackeen, Bret Barker, Laurence Vanhelsuwé
   JavaÔÚÉè¼Æʱ³ä·Ö¿¼ÂÇÁËÏß³Ì,Òò´ËÔÚJavaÖÐÏ̵߳IJÙ×÷±ÈÆäËûÓïÑÔÒª¼òµ¥¡£Ö»ÐèÉú³ÉÒ»¸öThreadÀàµÄʵÀý±ã¿É´´½¨Ò»¸öỊ̈߳¬È»ºóµ÷ÓÃstart()·½·¨Ï߳̾ÍÆô¶¯ÁË¡£
 &nbs ......

±±¾©£ºJAVA¸ß¼¶¹¤³Ìʦ

ÓÉÓÚ¹«Ë¾ÒµÎñÔö³¤£¬ÏÖ¼±ÐèÕÐƸ·ûºÏÈçÏÂÌõ¼þJAVA¸ß¼¶Èí¼þ¹¤³Ìʦ  Èô¸ÉÃû
1¡¢¾ßÓÐÁ¼ºÃµÄjava¼¼Êõ֪ʶºÍ¾­Ñ飻
2¡¢¾ß±¸Á¼ºÃµÄ½â¾öÎÊÌâµÄÄÜÁ¦ÒÔ¼°³öÉ«µÄÍŶӺÏ×÷ÄÜÁ¦£»
3¡¢ÊìϤJ2EE¼Ü¹¹ºÍ¿ª·¢Ä£Ê½£¬ÊìϤMVCÉè¼Æģʽ£»
4¡¢ÊìϤhibernate¡¢struts2¡¢spring£»
5¡¢ÄÜ°´Õչ淶µÄÈí¼þ¿ª·¢Á÷³Ì£¬Íê³ÉÈí¼þµÄÐèÇó¡¢Éè¼Æ¡¢±àÂëº ......

javaÈÕÆÚ´¦ÀíSystem£¨1£©

È¡µÃµ±Ç°ÏµÍ³Ê±¼ä   System.currentTimeMillis()
·µ»ØºÁÃëʱ¼ä£¬ÎªlongÐÍÕûÊý£¬
¸Ãº¯ÊýÔÚ½øÐÐϵͳÐÔÄܼà¿Øʱ×î³£Óõ½
Àý£º
  long start = System.currentTimeMillis();
  //Òª¼à¿ØµÄ´úÂë¶Î
  long end = System.currentTimeMillis();
  System.out.println(end-start);
ÓÐʱҪ¼à¿Øµ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ