想要 SAXParseException return -1

want SAXParseException return -1

当发生 SAXParseException 时,我希望异常为 return -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 

听起来你需要:

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