📄 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 + -