[英]java.io.EOFException: Unexpected end of ZLIB input stream
Testing my tar.gz extraction tool, I found thrown the exception:测试我的 tar.gz 提取工具,我发现抛出了异常:
java.io.EOFException: Unexpected end of ZLIB input stream at java.util.zip.InflaterInputStream.fill(Unknown Source) at java.util.zip.InflaterInputStream.read(Unknown Source) at java.util.zip.GZIPInputStream.read(Unknown Source) at sun.nio.cs.StreamDecoder.readBytes(Unknown Source) at sun.nio.cs.StreamDecoder.implRead(Unknown Source) at sun.nio.cs.StreamDecoder.read(Unknown Source) at java.io.InputStreamReader.read(Unknown Source) at java.io.BufferedReader.fill(Unknown Source) at java.io.BufferedReader.readLine(Unknown Source) at java.io.BufferedReader.readLine(Unknown Source) at it.uniroma2.informatica.specialistica.IO.ScanCompressedFileUtil.main(ScanCompressedFileUtil.java:60
So the code at line 60 is:所以第 60 行的代码是:
BufferedReader bufLe= reader.remove();
try {
while ( bufLe.ready() ){
System.out.println(" "+bufLe.readLine());
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
where calling buffer.readLine() , throws the exception.其中调用buffer.readLine() ,抛出异常。 When I open the tar.gz, I kept the stream of all single file, like BuffReader then I put them to a linkedList, and then i Closed the buffer of the file tar.gz opened.当我打开 tar.gz 时,我保留了所有单个文件的流,比如 BuffReader 然后我把它们放到一个链表中,然后我关闭了打开的文件 tar.gz 的缓冲区。
But When I pop an element within the linked list and then try to read line by line, I have the execption.但是当我在链表中弹出一个元素然后尝试逐行读取时,我得到了执行。
Why do I have this exception?为什么我有这个例外? Maybe I am wrong somethinh when I iterate through the files within the tar.gz?当我遍历 tar.gz 中的文件时,也许我错了?
To doing so, I have the code:为此,我有代码:
TarInputStream is = new TarInputStream(gzipInputStream);
TarEntry entryx = null;
try {
while((entryx = is.getNextEntry()) != null) {
InputStream tmpInx = new StreamingTarEntry(is, entryx.getSize());
// questo viene invocato perchè il file da lettere è un file txt
manageTxtinsideTAR(tmpInx , buffer);
// I add the stream to a linked list
THe class STREAMINGTARENTRY, extends FilterInputStream, so it's only wraps the stream. STREAMINGTARENTRY 类扩展了 FilterInputStream,因此它只包装流。
It could be related to the JVM bug http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=53ede10dc8803210b03577eac43?bug_id=6519463它可能与 JVM 错误有关http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=53ede10dc8803210b03577eac43?bug_id=6519463
See my answer for more details on this related question https://stackoverflow.com/a/18845169/2463453有关此相关问题的更多详细信息,请参阅我的回答https://stackoverflow.com/a/18845169/2463453
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.