问答详情
源自:2-3 使用 DOM 解析XML 文件的节点名和节点值

为什么我的总是出现这个错误 java.net.MalformedURLException: unknown protocol: g

我写的程序老是出现这么错误,百思无果,复制老师的代码之后依然出现该错误(后面就连Xml内容都一样)。以下是错误

java.net.MalformedURLException: unknown protocol: g

at java.net.URL.<init>(URL.java:600)

at java.net.URL.<init>(URL.java:490)

at java.net.URL.<init>(URL.java:439)

at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:620)

at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:148)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:805)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)

at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)

at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)

at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)

at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:177)

at com.imooc.dom.Domtext.kjtext(Domtext.java:26)

at com.imooc.dom.Domtext.main(Domtext.java:132)


提问者:qq_筑城以北_04274162 2017-04-17 21:00

个回答

  • Mrwang5
    2017-04-18 17:35:18

    可能是你文件的路径包含空格或者非法字符