config/cfg.xml<?xmlversion ="1.0"encoding="UTF-8"?>
config/cfg.xml
package config;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class ConfigReader {
public static void readConfig()throws Exception
{
SAXReader reader=new SAXReader();
Document doc= reader.read("config/cfg.xml");
Element game=doc.getRootElement();
Element frame=game.element("frame");
String str=frame.attributeValue("width");
System.out.print(str);
}
public static void main(String[]args) throws Exception
{
readConfig();
}
}
为什么编译的时候没有错误,运行的时候就出错了啊
展开