java读取xml文件报“org.xml.sax.SAXParseException: Premature end of file
2014-03-08 07:06
621 查看
背景:java读取xml文件,xml文件内容只有“<?xml version="1.0" encoding="UTF-8"?>”一行
java读取该xml文件时,报“org.xml.sax.SAXParseException: Premature end of file”错误。
java解析xml文件时抛出异常:
org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:98)
at com.eos.system.utility.XmlUtil.parseFileThrowsException(XmlUtil.java:1788)
解决方案:发现xml文件中只有<?xml version="1.0" encoding="UTF-8"?>一句,没有内容,随便添加一个空的标签后,异常就没有了
文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<xml-body>
</xml-body>
java读取该xml文件时,报“org.xml.sax.SAXParseException: Premature end of file”错误。
java解析xml文件时抛出异常:
org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:98)
at com.eos.system.utility.XmlUtil.parseFileThrowsException(XmlUtil.java:1788)
解决方案:发现xml文件中只有<?xml version="1.0" encoding="UTF-8"?>一句,没有内容,随便添加一个空的标签后,异常就没有了
文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<xml-body>
</xml-body>
相关文章推荐
- java读取xml文件报“org.xml.sax.SAXParseException: Premature end of file”
- org.xml.sax.SAXParseException: Premature end of file 错误
- faultString: org.xml.sax.SAXParseException: Premature end of file问题解决方案
- org.xml.sax.SAXParseException: Premature end of file
- org.xml.sax.SAXParseException: Premature end of file
- Android解决异常org.xml.sax.SAXParseException: Unexpected end of document
- spring应用启动异常 org.xml.sax.SAXParseException; Premature end of file.
- 解决SAXParseException: Premature end of file
- Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed charac
- Caused by: org.xml.sax.SAXParseException; systemId: file:/opt/apache-nutch-2.2.1/runtime/local/conf/
- nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
- org.xml.sax.SAXParseException: The content of element type "configuration" must match
- saxReader.read()报org.xml.sax.SAXParseException: Invalid byte 2 of 2-byte UTF-8 sequence.
- spring xml配置文件中指定的xsd文件读取不到了org.xml.sax.SAXParseException:
- org.xml.sax.SAXParseException: Invalid byte 3 of 3-byte UTF-8 sequence
- org.xml.sax.SAXParseException: Invalid byte 3 of 3-byte UTF-8 sequence
- 严重: Parse error in application web.xml file at jndi:/localhost/ipws/WEB-INF/web.xml java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml
- Caused by: org.xml.sax.SAXParseException; systemId: file:/home/hadoop/hive-0.12.0/conf/hive-site.xml; lineNumber: 5; columnNumber: 2; The markup in the document following the root element must be well
- org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or
- Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.