java¶ÁÈ¡XMLÎļþÀïÃæµÄÊý¾ÝÖ®DOMʵÏÖ
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.*;
public class ReadXML {
private File file;
public ReadXML(String filename){
File file=new File(filename);
this.file=file;
}
/**
*
* @return the instance of Document
*/
public Document getDOM(){
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
DocumentBuilder db;
Document document=null;
try{
db=dbf.newDocumentBuilder();
document=db.parse(file);
}catch(Exception e ){
e.printStackTrace();
}
return document;
}
/**
*
* @param tagName
* @return
*/
public String getInfoByTagName(String tagName)
{
String info="";
Document document=this.getDOM();
//»ñÈ¡NodeName ΪtagNameµÄ½Úµã×é
NodeList nl=document.getElementsByTagName(tagName);
for(int i=0;i<nl.getLength();i++)
{
info+=tagName+"[+"+i+"+]"+"\n";
Node node=nl.item(i);
//Èç¹ûµ±Ç°½ÚµãÓÐ×ӽڵ㣨ÕâÀï Ö»¿¼ÂÇ»¹ÓÐÒ»¼¶×Ó½ÚµãµÄÇé¿ö£©
if(node.hasChildNodes())
{
NodeList list=node.getChildNodes();
for(int j=0;j<list.getLength();j++)
{
Node childNode=list.item(j);
/* ²»¼ÓÕâ¸öIfÓï¾ä»áÅ׳ö
* Exception in thread "main" java.lang.NullPointerException
* at ReadXML.getInfoByTagName(ReadXML.java:59)
* at Test.main(Test.java:17)
*/
if(childNode.getFirstChild()!=null)
/* ¶ÔgetNodeValue()µÄ¹ý³Ì³¹µ×ÎÞÓï
* µ÷ÊÔÕâ¸öµØ·½µÄʱºò£¬ÔÚÍøÉϺÜÈÝÒ×ÕÒµ½ÁË
* Ôڵõ½ValueµÄʱºò±ØÐëÔÚ½Úµã¶ÔÏóºóÃæÏȵ÷ÓÃgetFirstChild()»òÕßgetChildNodes().item(0)
* ÔÒòºÜ¼òµ¥£¬µ«ÊDz»ÖªµÀÉè¼ÆÕßÎÊʲôҪÕâôÉè¼Æ
* ×î½üÔÚ¿´¡¶Be
Ïà¹ØÎĵµ£º
import java.util.Date;
public class TimeSpan
{
public final static TimeSpan ZERO = new TimeSpan(0);
private long _totalMilliSeconds = 0;
public TimeSpan(long totalMilliSeconds)
{
_totalMilliSeconds = totalMilliSeconds;
}
public TimeSpan(Date afterDate, Date beforeDat ......
ÎÒÔÚÍæÒ»¸öÍøÒ³ÓÎÏ·µÄʱºò×ÜÊǰ´Ò»¸ö¼ü¡£¾õ×ÅÀÛ¡£ËùÒÔ¾ÍдÁËÒ»¸ö³ÌÐò¡£
Robot r = new Robot();
// °´¼ü
r.keyPress(51);
// ÊÍ·Å
r.keyRelease(51);
ÓÃRobot Õâ¸öʵÏÖ×Ô¶¯»¯µÄÀà¾Í¿É×öµ½¡£ÊµÏÖÕâ¸öÓÎÏ·Ò»Ö±°´ÏÂÕâ¸ö¼ü×Ó¡£
Ò²¿ÉÒÔ×ö°´¼ü¾«ÁéÀàËÆµÄÈí¼þ¡£µ«ÊÇÕâ¸öÀàÖ»ÄÜÓ¦Óõ±Ç°´°¿Ú¡£ÔõôÄܰÑÕâ¸ö³ÌÐò¹Ì¶¨ÔÚij ......
JAVAÅäÖãº
1£º JAVA_HOME £º C:\Program Files\Java\jdk1.6.0_12
2£ºCLASSPATH £º .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
3£ºPATH £º %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
TomcatÅäÖ ......
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.huadoo.model.Area;
public class Aaaa {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
  ......