Bomberlatinos9
Bomberlatinos9

Reputation: 810

java.io.EOFException: Unexpected end of ZLIB input stream

Testing my tar.gz extraction tool, I found thrown the exception:

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:

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. 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.

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?

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.

Upvotes: 2

Views: 32879

Answers (1)

Stephan L
Stephan L

Reputation: 412

It could be related to the JVM bug https://bugs.java.com/bugdatabase/view_bug;jsessionid=53ede10dc8803210b03577eac43?bug_id=6519463

See my answer for more details on this related question https://stackoverflow.com/a/18845169/2463453

Upvotes: 5

Related Questions