Code example for DefaultHandler

    private DefaultHandler offline;
    public void setUp() throws Exception {
        parser = SAXParserFactory.newInstance().newSAXParser();
        offline = new OfflineContentHandler(new DefaultHandler());
    public void testExternalDTD() throws Exception {
        String xml =
            "<!DOCTYPE foo SYSTEM \"\"><foo/>"; 
        try { 
            parser.parse(new InputSource(new StringReader(xml)), offline);
        } catch (ConnectException e) {
            fail("Parser tried to access the external DTD:" + e);
Experience pair programming with AI  Get Codota for Java