我正在使用 JDOM 和 SAXBuilder 来解析 XML 文件,但我遇到了一个抛出此错误的文件问题:
java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(URL.java:574)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:518)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:986)
at com.foo.moo.MyClass.getValues(MyClass.java:321)
该行是:
Document document = null;
document = sxb.build(files.elementAt(i)); // This one
在网上做了一些研究后,我认为该错误与Java 1.6有关。
你怎么认为 ?
我的第一个猜测是您正在加载本地文件,例如:“c:/mylocalfile.xml”
但是这个URL不包含协议,比如http://
, ftp://
or file://
尝试 file://c:/mylocalfile.xml
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)