网络文件需要使用输入流来读取
所以获取网络文件的时候要用getInputStream(),如果是本地文件可以用getFile()
小例子
UrlResource urlResource = new UrlResource("http://www.slience.com/book.xml");
System.out.println("urlResource.getFilename()="+urlResource.getFilename());
System.out.println("urlResource.getDescription()="+urlResource.getDescription());
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(urlResource.getInputStream());
Element element = document.getRootElement();
List list = element.elements();
Iterator iterator = list.iterator();
while(iterator.hasNext()) {
Element element2 = (Element) iterator.next();
System.out.println(element2.getName()+":"+element2.getText());
}