我正在配置 SAX 解析器以读取 RSS 提要。这是它的外观:
public void processFeed(){
try{
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
InputStream stream = new URL(url).openStream();
XMLReader reader = parser.getXMLReader();
reader.setContentHandler(this);
reader.parse(new InputSource(stream));
}catch(Exception e){
errorOccured = true;
}
}
问题是发生错误并且布尔值errorOccured
设置为true。有人可以告诉我为什么这会产生错误吗?