想要SAXParseException返回-1

时间:2015-03-12 11:07:33

标签: java exception return-value saxparseexception

当发生SAXParseException时,我希望异常返回-1。但我不知道应该怎么做,因为我无法处理这些异常。任何想法我应该怎么做?在异常发生的那一刻打印出来:

VARNING: org.xml.sax.SAXParseException: s4s-elt-character: Non-whitespace 
characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw '1'.

Process finished with exit code 0 

1 个答案:

答案 0 :(得分:0)

听起来像你需要:

try {
  // whatever code might throw SAXParseException
} catch (SAXParseException e) {
  return -1;
}