unknown host exception while parsing an xml file

前端 未结 3 435
粉色の甜心
粉色の甜心 2021-01-18 09:30

when i am trying to parse an xml, i am getting following exception :-

java.net.UnknownHostException: hibernate.sourceforge.net
    at java.net.AbstractPlainS         


        
3条回答
  •  粉色の甜心
    2021-01-18 10:08

    i used the following code and this is working fine for me..

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();  
    dbf.setValidating(false);
    DocumentBuilder db = dbf.newDocumentBuilder();
    db.setEntityResolver(new EntityResolver() {
      @Override
      public InputSource resolveEntity(String arg0, String arg1)
            throws SAXException, IOException {
        if(arg0.contains("Hibernate")) {
            return new InputSource(new StringReader(""));
        } else {
            // TODO Auto-generated method stub
            return null;
        }
      }
    });
    Document doc = db.parse(hbmFile);
    

提交回复
热议问题