I have a class extending org.xml.sax.ext.DefaultHandler2
in which I override
public void startElement(String uri,
String localName, String qName, Attributes attributes) throws SAXException
which is originally from DefaultHandler2
's supertype org.xml.sax.helpers.DefaultHandler
.
When I try to parse an XML file encoded in UTF-8 with BOM, it throws an exception
[Fatal Error] :1:1: Content is not allowed in prolog.
as well-documented elsewhere.
Now, I'd like to catch this exception in my code, i.e., my class extending DefaultHandler2
, but because the eception is thrown on the method itself, I cannot see a way to do this.
Is there one? Or am I stuck with the original exception?