?? readtimeandlocation.java
字號:
package Bean;
import java.io.*;
import java.util.*;
import java.io.IOException;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
public class readTimeAndLocation
{
private String s1="D:/軟件工程課程參數設置/info.xml";
private String dateInfoPath="";
private String timeGet="";
public readTimeAndLocation()
{
cmpTime();
}
public void setTimeGet(String s)
{
timeGet=s;
}
public String getTimeGet()
{
return timeGet;
}
public void setDateInfoPath(String s)
{
dateInfoPath=s;
}
public String getDateInfoPath()
{
return dateInfoPath;
}
public String cmpTime()
{
try
{
File xmlFile=new File(s1);
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builder=factory.newDocumentBuilder();
Document doc=builder.parse(xmlFile);
NodeList nodeList=doc.getElementsByTagName("Documents");
for(int i=0;i<nodeList.getLength();i++)
{
if(doc.getElementsByTagName("HomeworkType").item(i).getFirstChild().getNodeValue().equals("時間數據上交起始時間"))
{
timeGet=doc.getElementsByTagName("SubmitDate").item(i).getFirstChild().getNodeValue();
}
if(doc.getElementsByTagName("HomeworkType").item(i).getFirstChild().getNodeValue().equals("upload文件夾位置"))
{
dateInfoPath=doc.getElementsByTagName("SubmitDate").item(i).getFirstChild().getNodeValue();
}
}
}
catch(Exception e)
{
return "wrong";
}
return "right";
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -