SAXReader 解析xml解析报错。关于读取xml文件是的格式设置问题。
public Document BufferStreamXML(String spec, int size) {
URL url;
Document document=null;
List<Item> list=new ArrayList();
try {
BufferedInputStream bis = null;
try {
url = new URL(spec);
bis = new BufferedInputStream(url.openStream(), size);
SAXReader reader=new SAXReader();
//reader.setEncoding("GB2312"); //因为添加了这行,读取xml文件老是失败。看了老半天都没有想到是这里出错了。下次切记。
try {
document=reader.read(bis);
} catch (DocumentException e) {
e.printStackTrace();
}
} finally {
if (bis != null)
bis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
return document;
}
春天到了,今天风还是好大。一天天过的真快