同时执行以下代码:
doc = builder.parse(file);其中doc是org.w3c.dom.Document的实例,builder是javax.xml.parsers.DocumentBuilder的实例,我得到了以下异常:
Exception in thread "main" java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at com.acme.ItemToThetaValues.createFiles(ItemToThetaValues.java:47)它在文件的这一行卡住了:
<!DOCTYPE questestinterop SYSTEM "C:\Program Files\Acme\parsers\acme_full.dtd">我没有在我的机器上得到这个错误,而用户在他的机器上得到了这个错误。我们都在使用Sun JRE的版本6。当他在路径中使用双反斜杠而不是单反斜杠时,以及当他使用正斜杠而不是反斜杠时,也会发生这种错误。
首先,XML是否正确?路径表达是否正确?其次,为什么这个错误发生在一台计算机上,而不是在另一台计算机上?
发布于 2010-05-27 04:33:52
原来我们使用的是不同版本的JRE。他用的是1.6.0_06,而我用的是java版本"1.6.0_20“。
这是一个bug in the 1.6.0_06 version of the JRE。
https://stackoverflow.com/questions/2916192
复制相似问题