`
xiaoyu1985ban
  • 浏览: 130114 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

org.xml.sax.SAXParseException: Content is not allowed in trailing section. .

    博客分类:
  • Java
 
阅读更多

总结一下,这个问题主要出现的原因有两点。

 

1、XML内容不正确,比如多个空格,换行等等。需要仔细排查;

2、使用Stream读取流文件不正确,详细如下:

 

读写文件时,一般采用的是每次从inputStream中read 一个有固定大小的byte array时,这时候在

 

byte[] array = new byte[1024];

 

BufferedInputStream buffInput = new BufferedInputStream(inputStream);

FileOutputStream fileOS = new FileOutputStream(targetFile);

BufferedOutputStream buffOS = new BufferedOutputStream(fileOS);

int word = 0;

while ((word = buffInput.read(array)) != -1){

buffOS.write(array);

}

 

 

上面的写法,如果最后一次read到array中不足1024的时候,前一次read的byte同样会出现在byte[]中,从而导致XML解析失败。因此可以采用下面的方法:

 

 

BufferedInputStream buffInput = new BufferedInputStream(inputStream);

FileOutputStream fileOS = new FileOutputStream(targetFile);

BufferedOutputStream buffOS = new BufferedOutputStream(fileOS);

int word = 0;

while ((word = buffInput.read()) != -1){

buffOS.write(word);

}

 

 

 

1、进入在netbeans的安装目录;

2、定位到etc目录里

3、编辑找到netbeans.conf文件,把netbeans_jdkhome路径设置为当前JDK路径。

解决!

 

 

 

 

声明:

文章来自于ITeye,欢迎访问我的博客:xiaoyu1985ban.iteye.com

ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。若作者同意转载,必须以超链接形式标明文章原始出处和作者。

分享到:
评论

相关推荐

    org.xml.sax.SAXException: Invalid element

    NULL 博文链接:https://wilian.iteye.com/blog/1992365

    BeRoot, 特权升级项目 Windows/Linux/Mac.zip

    BeRoot, 特权升级项目 Windows/Linux/Mac BeRoot项目BeRoot项目是一个发布工具,用于检查常见的以找到一种方法来升级我们的特权。它已经被添加到 pupy 项目作为一个post开发模块( 所以它将在内存中执行而不需要触摸...

    php解析xml提示Invalid byte 1 of 1-byte UTF-8 sequence错误的处理方法

    错误提示Invalid byte 1 of 1-byte UTF-8 sequence原因分析在中文版的window下java...把xml的encoding属性值UTF-8改为UTF8org.xml.sax.SAXParseException: Content is not allowed in trailing section把先要解析和字符

    Matlab高阶谱分析(HOSA)工具箱及安装方法

    org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'area'. One of '{MathWorksID, type}' is expected. 运行hosaver: Warning: Could not find an exact ...

    java调用net开发的webservice实例

    javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing '- WSDL Document -'.: org.xml.sax.SAXParseException: The element type "p" must be terminated by the matching end-tag ...

    android layout XML解析错误的解决方法

    org.xml.sax.SAXParseException: PI must not start with xml (position:unknown xm@3:5 in java.io.InputStreamReader@43e4b480) 经过多次查找确认XML语法没错误。 问题原因: 为XML文件第一行格式错误,仔细修改第

    2020-10-29日自己保存华为短信开发包smproxy.rar

    好多版本是会报错的,[Fatal Error] :24:28: An ... org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xd863) was found in the element content of the documen.,这个版本是纠正过后重新打包做的

    华为短信开发包smproxy.jar,完美无bug版

    好多版本是会报错的,[Fatal Error] :24:28: An ... org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xd863) was found in the element content of the documen.,这个版本是纠正过后重新打包做的

    SAX.java 操作xml文件

    SAX.java 操作xml文件SAX.java 操作xml文件SAX.java 操作xml文件SAX.java 操作xml文件SAX.java 操作xml文件SAX.java 操作xml文件SAX.java 操作xml文件SAX.java 操作xml文件

    解决dubbo启动的时候报错,无法读取方案文档 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd'

    解决启动dubbo项目的时候出现,无法读取方案文档 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd',其实在你本地把dubbo.jar文件解压,然后在META-INF下边就有个dubbo.xsd,就是他

    Wrox.Beginning.Xml.2ed-Xml.Schemas.Soap.Xslt.Dom.And.Sax.2.0.rar

    sax2 SAX的工作原理简单地说就是对文档进行顺序扫描,当扫描到文档(document)开始与结束、元素(element)开始与结束、文档(document)结束等地方时通知事件处理函数,由事件处理函数做相应动作,然后继续同样的...

    dubbo.xsd 下载

    org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd', because 1) could not find the document; 2) the document could ...

    XML Programming Bible

    Chapter 6: Parsing XML with SAX . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Chapter 7: XSLT Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Chapter 8: XSL ...

    java SE API

    JavaTM 2 Platform Standard Ed. 5.0 所有类 软件包 java.applet java.awt java.awt.color java.awt.datatransfer java.awt.dnd java.awt.event ...javax.xml javax.xml.datatype ...org.xml.sax.helpers

    htmlparser

    org.htmlparser.sax.Attributes.class org.htmlparser.sax.Feedback.class org.htmlparser.sax.Locator.class org.htmlparser.sax.XMLReader.class org.htmlparser.scanners.CompositeTagScanner.class org....

    解析XML所需的jar sax.jar

    解析XML所需的jar sax.jar

    dom.sax.pull解析

    Java解析XML的三种方式 ...Ø 2、SAX(org.xml.sax) Ø SimpleAPI for XML,以事件的形式通知程序,对Xml进行解析。 Ø 3、XMLPULL(org.xmlpull.v1) Ø 类似于SAX方式,程序以“拉取”的方式对Xml进行解析。

    J2EE.v1.3.1.API.chm

    v 1.3 API Specification Compiled to .CHM by 貀vind Stegard Packages javax.activation javax.ejb javax.ejb.spi ...c.dom org.xml.sax org.xml.sax.ext org.xml.sax.helpers

    Javase-6.0_中文API_HTML(最新更新)

    javase 中文API 最新版 ******************************* JavaTM 2 Platform Standard Ed.... 所有类软件包 java.applet java.awt ...javax.xml javax.xml.bind javax.xml.bind.annotation ...org.xml.sax.helpers

    jdk 中文版

    java jdk api帮助文档中文版 JavaTM Platform Standard Ed. 6 所有类 软件包 java.applet java.awt java.awt.color java.awt.datatransfer java.awt.dnd ...javax.xml ...org.xml.sax.helpers

Global site tag (gtag.js) - Google Analytics