我的java考试系统总是读取试题为空  试题文件采用xml文件
大家帮忙看看 哪里出毛病了 谢谢.
下面是代码import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.io.*;
import java.util.*;
import java.lang.String;
public class ReadTestquestion
{   static int z;
static String filename ,
correctAnswer = "",
testContent = "",
selection = "",
selection1 = "";
int score = 0;
long time = 0;
boolean 完成考试 = false;
FileReader in = null;
String te;
Node currentNode, textNode, currentNode1;
NodeList childNodes, childNodes1, childNodes2;
String temp;
String a[] = new String[100];
StringBuffer temp1,temp2;
public void setFilename(String name)
{
filename = name;
score = 0;
selection = "";
try
{
if (in != null && temp != null)
{
in.close();
}
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new File(filename));
Node root = document.getDocumentElement(); childNodes = root.getChildNodes();
currentNode = childNodes.item(1);
String s = currentNode.getNodeName();
String s1 = currentNode.getNodeValue();
childNodes1 = currentNode.getChildNodes();
textNode = childNodes1.item(0);
String q = textNode.getNodeName();
String temp = textNode.getNodeValue();
StringTokenizer token = new StringTokenizer(temp, ":");
int hour = Integer.parseInt(token.nextToken());
int minute = Integer.parseInt(token.nextToken());
int second = Integer.parseInt(token.nextToken());
time = 1000 * (second + minute * 60 + hour * 60 * 60);
}
catch (Exception e)
{
System.out.print("Err happend here. " + e.getMessage());
testContent = "请选择试题文件!";
}
}
public String getFilename()
{
return filename;
}
public long getTime()
{
return time;
}
public void set完成考试(boolean b)
{
完成考试 = b;
}
public boolean get完成考试()
{
return 完成考试;
}

public String getTestContent()
{ try
{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new File(filename));
Node root = document.getDocumentElement(); childNodes = root.getChildNodes();
currentNode = childNodes.item(1);
String s = currentNode.getNodeName();
String s1 = currentNode.getNodeValue();
childNodes1 = currentNode.getChildNodes();
textNode = childNodes1.item(0);
String q = textNode.getNodeName();
String temp = textNode.getNodeValue(); currentNode = childNodes.item(3);
String ss = currentNode.getNodeName();
String ss1 = currentNode.getNodeValue();
childNodes1 = currentNode.getChildNodes();
textNode = childNodes1.item(0);
String qq = textNode.getNodeName();
String te= textNode.getNodeValue();
temp1 = new StringBuffer();
temp1.append(te);
             if (temp != null)
{  
childNodes=root.getChildNodes();
currentNode1=childNodes.item(5);
q = currentNode1.getNodeName();
childNodes1=currentNode1.getChildNodes() ;
currentNode1 = childNodes1.item(z + 1);
z=z+2;
childNodes1=currentNode1.getChildNodes();
textNode = childNodes1.item(0);
temp = textNode.getNodeValue();
{
      if (temp.compareTo("ended")!=0 )
{
  testContent = new String(temp);
}
else
{
in.close();
完成考试 = true;
}
   }
}
else
{
testContent = new String("请选择试题文件");
}
}
catch (Exception e)
{
System.out.println(" "+e.getMessage());
testContent = "当前试题内容为空,考试结束!!";
}
return testContent;
}
public void setSelection(String s)
{
selection = selection + s;
}
public int getScore()
{
score = 0;
int length1 = selection.length();
int length2 = temp1.length();
int min = Math.min(length1, length2);
for (int j= 0; j < min; j++)
{try
{
if (selection.charAt(j) == temp1.charAt(j))
score++;
}
catch (StringIndexOutOfBoundsException e)
{
z = 0;
}
}
return score;
}
public String getMessages()
{
int length1 = selection.length();
int length2 = temp1.length();
int length = Math.min(length1, length2);
String message = "正确答案:" +temp1+ "\n" + "你的回答:" + selection + "\n";
return message;
}
}
<?xml version=”1.0”  encoding=”UTF-8”  standalone=”yes”?>
<!DOCTYPE Apple[
<!ELEMENT Apple (examtime,reply,exam)>
<!ELEMENT exam (question+,end)>
<!ELEMENT examtime (#PCDATA)>
<!ELEMENT reply (#PCDATA)>
<!ELEMENT question (#PCDATA)>
<!ELEMENT end (#PCDATA)>
]>
<Apple>
     <examtime>……</examtime>
     <reply>……</reply>
     <exam>
         <question>
              <!--以下为一道试题的内容-->
              ……………………………………………….
                  ……………………………………………….
             </question>
              <question>
                  <!--以下为一道试题的内容-->
                   ………………………………………………
                   ………………………………………………
              </question>
              <!--以下为试题题目-->
              ……………………………………………………..
              ……………………………………………………..
              ……………………………………………………..
              <end>ended</end>
          </exam>
      </Apple>