`
xitong
  • 浏览: 6417711 次
文章分类
社区版块
存档分类
最新评论

dom4j解决Premature end of file

 
阅读更多

使用dom4j解析来自InputStream中的XML内容,发生异常:Premature end of file

原来是这个InputStream已经读过了,在读入dom4j时,不是从开头读的,因此报错。

详细解释如下:来自http://forums.sun.com/thread.jspa?threadID=641465

Problem: Input stream is opened and read bytes from it, passed the same to document builder to parse method. so it caused the exception saying premature end of file.

Solution: Pass fresh input stream which is opened and not read anything (bytes) before passing to parse method of DocumentBuilder object.

分享到:
评论

相关推荐

    caffe官网的一些翻译

    #### 4. Fine-tuning CaffeNet for Style Recognition on “Flickr Style” Data **解释** - **数据库**: FlickrStyle图像库与ImageNet数据集相似。 - **预训练模型**: 使用预训练的bvlc_reference_caffenet模型。 -...

    解压cpio文件

    无论是单个文件还是多个文件,都有相应的解决方案。这些命令在Linux系统管理中非常实用,能够帮助我们高效地处理各种文件归档任务。掌握了这些技能,无论是日常工作中遇到的问题还是项目开发中的需求,都能够更加...

    QT,JPEG解码源代码(已完成)

    /* 04h Length of APP0 Field */ BYTE Identifier[5]; /* 06h "JFIF" (zero terminated) Id String */ BYTE Version[2]; /* 0Bh JFIF Format Revision */ BYTE Units; /* 0Dh Units used for Resolution */ ...

    FDTD Java example codes

    4. **生物医学应用:** 计算电磁场在生物组织中的传播,研究电磁兼容性和生物效应。 综上所述,`FDTD Java example codes`是一个使用Java编程语言实现的电磁场3D计算项目,它提供了对复杂电磁现象进行数值模拟的...

    丑陋版qt网络传输jpeg图片

    4. 将接收到的数据保存到本地文件,如果是JPEG图片,应确保以二进制模式打开文件。 客户端这边的步骤是: 1. 创建`QTcpSocket`对象,连接到服务器的IP地址和端口。 2. 打开本地JPEG图片文件,使用`QFile`类读取图片...

    QT 生成QXlsx库,亲测可用

    4. **集成到QT项目**:将生成的库文件添加到你的QT项目中。在QT项目的.pro文件中,使用`LIBS`变量指定库的路径。例如,对于动态库,添加`LIBS += -L/path/to/library -lqxlsx`。 5. **使用QXlsx库**:现在,你可以...

    PHP Parse Error: syntax error, unexpected $end 错误的解决办法

    4. 文件跳转使用header函数时出现错误。PHP中的header函数用于进行HTTP头的传输。使用header函数时必须确保在脚本的最前面(即在任何输出发送到浏览器之前)调用它。如果在header函数调用之前有任何输出(哪怕是空格...

    解决java远程调试ClosedConnectionException错误

    解决Failed to connect to remote VM com.sun.jdi.connect.spi.ClosedConnectionException错误,tomcat远程调试

    C++用zlib进行数据的节约(gzip)

    throw std::runtime_error("Premature end of input file"); } gzclose(gzipFile); inputFile.close(); } ``` 在解压缩方面,我们可以使用`gzopen`以读模式打开gzip文件,然后通过`gzread`读取解压缩后的数据...

    由Apache 500错误引出的临时文件问题分析解决

    查看apache日志,发觉是mod_fcgid模块异常,提示”Connection reset by peer:mod_fcgid:error reading data from FastCGI server”、”Premature end of script headers:index.php”、”process /usr/… apache/cgi-...

    dpkg_1.17.5ubuntu5.8.tar

    此版本解决dpkg报错dpkg-deb: error: archive 'device-tree-compiler_1.4.5-3_amd64.deb' has premature member 'control.tar.xz' before 'control.tar.gz' bug

    UNIX Network Programming Volume 2(Unix网络编程卷2英文版)

    15.11 premature termination of client or server 390 15.12 summary 397 chapter 16. sun rpc 16.1 introduction 399 16.2 multithreading 407 16.3 server binding 411 16.4 authentication 414 16.5 ...

    cxf客户端(对象,上传与下载文件支持断点传输)

    connection.setRequestProperty("Range", "bytes=" + startByte + "-" + endByte); InputStream in = connection.getInputStream(); ``` 服务端需要支持处理这种请求,并返回206 Partial Content状态码,同时在...

    hessdroid_android

    已经解决了第一次连接报:com.caucho.hessian.client.HessianConnectionException: 500: java.io.EOFException

    Active Cell Balancing in Battery

    a premature failure of the whole battery. Cell balancing is a way of compensating for these weaker cells by equalizing the charge on all the cells in the chain, thus extending the battery life.

    java.security.InvalidKeyException:illegal Key Size

    4. 重启你的应用程序或服务器,使新的策略生效。 安装完不受限的JCE策略后,你应该能够使用任意大小的密钥进行加密操作,从而满足微信开发中的高级安全需求。但是,要注意的是,这个更改可能违反了你所在国家或地区...

    packaging-chapter-06-databook.pdf

    A malfunction in these components or boards can occur immediately or the apparatus may perform for weeks, months, or even years before an unpredictable and premature breakdown causes a field failure.

    AIS-PSO.rar_PSO-AIS_The Space Between_immunity algorithm_optimiz

    however, PSO is easy to get trapped in local extremum, to have premature convergence or stagnation. In order to help PSO strike a balance between individual diversity and swarm convergence, this ...

    acpi控制笔记本风扇转速

    fields at the end of some of the subtables. The disassembler now emits a comment if a buffer appears to be a ResourceTemplate, but cannot be disassembled as such because the EndTag does not appear at...

Global site tag (gtag.js) - Google Analytics