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ŵÂüµ×µÄÒ»µãСÀúÊ·
×î½üºÜ¶àÈËÎÊJavaŵÂüµ×ÊÇʲôÒâ˼£¬×÷ΪJavaŵÂüµ×µÄÒ»ÃûÀÏͬ־£¬ÎÒ¼òµ¥µÄ½éÉÜÏÂJavaŵÂüµ×¡£
JavaŵÂüµ×³ÉÁ¢ÓÚ2008Äê7ÔÂ29ÈÕ£¬ÔÚÒ»¸öÈȺ¹³¯ÌìµÄÈÕ×ÓÀ¼¸¸öÂú»³Ï£ÍûµÄÓÐÖ¾ÇàÄê£¬×øÔÚÏæ½ºÓ°ø£¬Ì¸×Å×Ô¼ºÀíÏ룬ÆäÖÐÒ»ÈË˵£¬¼ÙÈçÎÒÃÇÓÐ×Ô¼ºµÄÍŶӸÃÓжàºÃ£¬ÓÚÊ ......
Æ¥ÅäÌØ¶¨Êý×Ö£º
^[1-9]d*$¡¡ ¡¡ //Æ¥ÅäÕýÕûÊý
^-[1-9]d*$ ¡¡ //Æ¥Å为ÕûÊý
^-?[1-9]d*$¡¡¡¡ //Æ¥ÅäÕûÊý
^[1-9]d*|0$¡¡ //Æ¥Åä·Ç¸ºÕûÊý£¨ÕýÕûÊý + 0£©
^-[1-9]d*|0$¡¡¡¡ //Æ¥Åä·ÇÕýÕûÊý£¨¸ºÕûÊý + 0£©
^[1-9]d*.d*|0.d*[1-9]d*$¡¡¡¡ //Æ¥ÅäÕý¸¡µãÊý
^-([1-9]d*.d*|0.d*[1-9]d*)$¡¡ //Æ¥Å为¸¡µãÊý
^-?([1-9]d*.d*| ......
JAVA¶¨Ê±Ö´ÐÐÈÎÎñµÄÈýÖÖ·½·¨
1) java.util.Timer
Õâ¸ö·½·¨Ó¦¸ÃÊÇ×î³£Óõ쬲»¹ýÕâ¸ö·½·¨ÐèÒªÊÖ¹¤Æô¶¯ÄãµÄÈÎÎñ£º
Timer timer=new Timer();
timer.schedule(new ListByDayTimerTask(),10000,86400000);
ÕâÀïµÄListByDayTimerTaskÀà±ØÐëextends TimerTaskÀïÃæµÄrun()·½·¨¡£
2) ServletContextListener
Õâ¸ö·½·¨ ......
import java.io.*;
import java.math.*;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner cin=new Scanner(System.in);
BigDecimal a; ......
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  ......