避免TDT 检查

   

 

class IgnoreDTDEntityResolver implements EntityResolver
    {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            return new InputSource(new ByteArrayInputStream(
                "".getBytes()));
        }
    }

 

 

SAXReader saxReader = new SAXReader();
        saxReader.setValidation(false);
        try {
            saxReader.setEntityResolver(new IgnoreDTDEntityResolver());
            document = saxReader.read(file);
        } catch (DocumentException e) {
            e.printStackTrace();
}

你可能感兴趣的:(XML)