java读取xml文件报“org.xml.sax.SAXParseException: Premature end of file”
2012-05-24 15:01
1281 查看
背景: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
- 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问题解决方案
- 解决SAXParseException: Premature end of file
- spring应用启动异常 org.xml.sax.SAXParseException; Premature end of file.
- Android解决异常org.xml.sax.SAXParseException: Unexpected end of document
- "org.xml.sax.SAXParseException: The content of element type "class" must match" 异常解决
- 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
- Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'xml-bod
- idea 创建Web Service Client 报错 java.lang.AssertionError: org.xml.sax.SAXParseException; systemId:
- org.xml.sax.SAXParseException; lineNumber: 18; columnNumber: 41; schema_reference无法读取方案文档 'http://co
- org.xml.sax.SAXParseException: The content of element type “sqlMapConfig” must match “(properties?,s
- Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
- org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'taglib'. 异常
- org.xml.sax.SAXParseException: The content of element type “sqlMapConfig” must match “(properties?,s
- Hbase单机模式启动提示org.xml.sax.SAXParseException; systemId: file:/opt/src/hbase/conf/hbase-site.xml; lineN
- Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed charac
- 【java】org.xml.sax.SAXParseException;在实体引用中, 实体名称必须紧跟在 '&' 后面。解决方法