本文整理匯總了Java中javax.xml.stream.XMLStreamException.getLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLStreamException.getLocation方法的具體用法?Java XMLStreamException.getLocation怎麽用?Java XMLStreamException.getLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.stream.XMLStreamException
的用法示例。
在下文中一共展示了XMLStreamException.getLocation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
public void parse() throws SAXException {
// parses from a StAX reader and generates SAX events which
// go through the repeater and are forwarded to the appropriate
// component
try {
reader.bridge();
} catch( XMLStreamException e ) {
// wrap it in a SAXException
SAXParseException se =
new SAXParseException2(
e.getMessage(),
null,
null,
e.getLocation() == null ? -1 : e.getLocation().getLineNumber(),
e.getLocation() == null ? -1 : e.getLocation().getColumnNumber(),
e);
// if the consumer sets an error handler, it is our responsibility
// to notify it.
if(errorHandler!=null)
errorHandler.fatalError(se);
// this is a fatal error. Even if the error handler
// returns, we will abort anyway.
throw se;
} finally {
try {
staxReader.close();
} catch(XMLStreamException xe) {
//falls through. Not much can be done.
}
}
}