Java : ParserConfigurationException (XML) with Examples

ParserConfigurationException (Java SE 23 & JDK 23) in Java with Examples.
You will find code samples for most of the ParserConfigurationException methods.


Summary

Indicates a serious configuration error.

Class diagram

try {
    final var factory = DocumentBuilderFactory.newInstance();
    factory.setFeature("dummy", true);
} catch (ParserConfigurationException e) {
    System.out.println(e);
}

// Result
// ↓
//javax.xml.parsers.ParserConfigurationException: Feature 'dummy' is not recognized.

Constructors

ParserConfigurationException ()

Create a new ParserConfigurationException with no detail message.

final var e = new ParserConfigurationException();
System.out.println(e); // javax.xml.parsers.ParserConfigurationException

ParserConfigurationException (String msg)

Create a new ParserConfigurationException with the String specified as an error message.

final var e = new ParserConfigurationException("abc");
System.out.println(e); // javax.xml.parsers.ParserConfigurationException: abc
System.out.println(e.getMessage()); // abc

Methods declared in Throwable

addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

Please see the link below.


Related posts

To top of page