Code example for XMLReader

Methods: parsesetEntityResolversetErrorHandler

0
        factory.setValidating(true);
        SAXParser parser = factory.newSAXParser();
        parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                XMLConstants.W3C_XML_SCHEMA_NS_URI);
        XMLReader reader = parser.getXMLReader();
        reader.setEntityResolver(new ResourceEntityResolver());
        reader.setErrorHandler(errorHandler);
        InputStream in = inputSupplier.getInput();
        try { 
            reader.parse(new InputSource(in));
        } finally { 
            in.close();
        } 
        // then return DOM 
        return newDocument(inputSupplier);
    } 
 
    private static class ResourceEntityResolver implements EntityResolver {
        @Nullable 
        public InputSource resolveEntity(String publicId, String systemId) throws IOException {
Connect your IDE to all the code out there  Get Codota for Java