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

JAVA ½âÎö XML

XMLÎļþʱºÜ¶àÏîÄ¿¾­³£Ê¹ÓõÄÅäÖûòÕßÆäËûÓÃ;µÄÎļþ¸ñʽ£¬½âÎöxmlÎļþ¸ñʽµÄ¿ª·¢°üÒ²ºÜ¶à£¬±¾ÎÄÖ÷ҪʹÓÃjava×Ô´øµÄDOM½âÎö°ü¡£±¾ÎÄÒÔÒ»¸öʵ¼ÊÀý×ÓÀ´½²Êö½âÎöxmlÎļþµÄ¹ý³Ì¡£
Ä¿±ê£º½âÎöÕâÑùÒ»¸öXMLÎļþ
employees.xml
=======ÄÚÈÝ¿ªÊ¼========
<?xml version="1.0" encoding="UTF-8"?>
<Personnel>
  <Employee type="permanent">
        <Name>Seagull</Name>
        <Id>3674</Id>
        <Age>34</Age>
   </Employee>
  <Employee type="contract">
        <Name>Robin</Name>
        <Id>3675</Id>
        <Age>25</Age>
    </Employee>
  <Employee type="permanent">
        <Name>Crow</Name>
        <Id>3676</Id>
        <Age>28</Age>
    </Employee>
</Personnel>
=======ÄÚÈݽáÊø========
Ä¿±êÊÇ£ºÊä³öÈçÏÂÄÚÈÝ
Employee Details - Name:Seagull, Type:permanent, Id:3674, Age:34.
Employee Details - Name:Robin, Type:contract, Id:3675, Age:25.
Employee Details - Name:Crow, Type:permanent, Id:3676, Age:28.
Ö÷Òª²½Öè
1£¬
Get a document builder using document builder factory and parse the xml
file to create a DOM object

Get a list of employee elements from the DOM

For each employee element get the id, name, age and type. Create an
employee value object and add it to the list.

At the end iterate through the list and print the employees to verify we
parsed it right.
a) »ñÈ¡document builder
public void parseXmlFile(){
//get the factory
DocumentBuilderFactory dbf = DocumentBu


Ïà¹ØÎĵµ£º

JAVA×Ô¶¯×°ÏäÓë²ðÏä

×Ô¶¯×°ÏäÓë²ðÏäµÄ¹¦ÄÜÊÂʵÉÏÊDZàÒëÆ÷À´°ïÄúµÄ棬±àÒëÆ÷ÔÚ±àÒëʱÆÚÒÀÄúËù±àдµÄÓï·¨£¬¾ö¶¨ÊÇ·ñ½øÐÐ×°Ïä»ò²ðÏ䶯×÷¡£ÀýÈ磺
Integer i = 100.Ï൱ÓÚ±àÒëÆ÷×Ô¶¯ÎªÄú×÷ÒÔϵÄÓï·¨±àÒ룺
Integer i = new Integer(100).ËùÒÔ×Ô¶¯×°ÏäÓë²ðÏäµÄ¹¦ÄÜÊÇËùνµÄ“±àÒëÆ÷ÃÛÌÇ”(Compiler Sugar)£¬ËäȻʹÓÃÕâ¸ö¹¦Äܷܺ½±ã£¬µ ......

JAVA¶¨Ê±Ö´ÐÐÈÎÎñµÄÈýÖÖ·½·¨

JAVA¶¨Ê±Ö´ÐÐÈÎÎñµÄÈýÖÖ·½·¨ 
1) java.util.Timer
Õâ¸ö·½·¨Ó¦¸ÃÊÇ×î³£Óõģ¬²»¹ýÕâ¸ö·½·¨ÐèÒªÊÖ¹¤Æô¶¯ÄãµÄÈÎÎñ£º
Timer timer=new Timer();
timer.schedule(new ListByDayTimerTask(),10000,86400000);
ÕâÀïµÄListByDayTimerTaskÀà±ØÐëextends TimerTaskÀïÃæµÄrun()·½·¨¡£
2) ServletContextListener
Õâ¸ö·½·¨ ......

java·¾¶

Ïà¶Ô·¾¶µÄ»ñµÃ
¡¡¡¡ ˵Ã÷:Ïà¶Ô·¾¶(¼´²»Ð´Ã÷ʱºòµ½µ×Ïà¶ÔË­)¾ù¿Éͨ¹ýÒÔÏ·½Ê½»ñµÃ£¨²»ÂÛÊÇÒ»°ãµÄjavaÏîÄ¿»¹ÊÇwebÏîÄ¿£©
¡¡¡¡ String
relativelyPath=System.getProperty("user.dir");
¡¡¡¡
ÉÏÊöÏà¶Ô·¾¶ÖУ¬javaÏîÄ¿ÖеÄÎļþÊÇÏà¶ÔÓÚÏîÄ¿µÄ¸ùĿ¼
¡¡¡¡ webÏîÄ¿ÖеÄÎļþ·¾¶ÊÓ²»Í¬µÄweb·þÎñÆ÷²»Í¬¶ø²»Í¬£¨tomcatÊÇ ......

JavaÎļþ²Ù×÷´óÈ«£¨ËÄ£©

26.Òƶ¯Ò»¸öÎļþ¼ÐÏÂËùÓÐÎļþµ½ÁíÒ»¸öĿ¼
//import java.io.*;
File movefile=new File(%%1);
File[] movefiles=movefile.listFiles();
for(int i=0;i<movefiles.length;i++){
if(movefiles[i].isFile()){
 int bytesum = 0;
 int byteread  ......

JAVAÓëC#±È½Ï

C#ÓëJAVAµÄÏà֮ͬ´¦:ÓÉÓÚC#ÓëJAVA¶¼ÊÇ»ùÓÚC++·¢Õ¹ÆðÀ´µÄ,Òò´Ë¶þÕßÖ®¼ä¾ßÓкܶàÏàËÆÖ®´¦,¾ßÌåÈçÏÂ:
¡¡¡¡1¡¢C#ºÍJAVAÓïÑԵıàÒë½á¹ûÊǶÀÁ¢ÓÚ¼ÆËã»úºÍ±à³ÌÓïÑԵģ¬¿ÉÖ´ÐÐÎļþ¿ÉÒÔÔÚÊܹÜÀíµÄÖ´ÐÐ
¡¡¡¡»·¾³ÖÐÖ´ÐУ»
¡¡¡¡2¡¢C#ºÍJAVAÓïÑÔ¶¼ÊDzÉÓÃÁË×Ô¶¯µÄÀ¬»ø»ØÊÕ»úÖÆ£»
¡¡¡¡3¡¢C#ºÍJAVAÓïÑÔ¶¼È¡ÏûÁËÖ¸Õë²Ù×÷£»
¡¡¡¡4¡¢ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ