How to quiet org.w3c.dom.Document?

the1matrix1

New Member
I have the following Java method:\[code\]private static Document documentFromFile(final File xmlFile){ Document document = null; try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder docBuilder = docBuilderFactory .newDocumentBuilder(); document = docBuilder.parse(xmlFile); document.getDocumentElement().normalize(); } catch(Exception exc) { // Handle exception... } return document;}\[/code\]In my test methods, if I pass this method a malformed XML file I get all sorts of error output on my console:\[quote\] [Fatal Error] :1:1: Content is not allowed in prolog. [Fatal Error] :1:1: Premature end of file.\[/quote\]I assume the culprit is \[code\]docBuilder.parse(xmlFile)\[/code\]. I'd like to be able to disable this default output and "silence" the document builder, and I don't see any setter methods on this object that allow me to do anything like that. Do I have an remedies here or am I stuck with this?
 
Back
Top