I have a class that is supposed to extract a given tar.gz file into a simple .tar file. But for some files this exception is thrown :
JavaScript
x
java.io.EOFException: Unexpected end of ZLIB input stream
The method managing the extraction look like this :
JavaScript
GZIPInputStream gzipInputStream;
FileOutputStream fileOutputStream;
byte data[] = new byte[BUFFER];
gzipInputStream = new GZIPInputStream( baseInputStream );
fileOutputStream = new FileOutputStream( destinationFile );
while ( ( count = gzipInputStream.read( data, 0, BUFFER ) ) != -1 )
{
fileOutputStream.write( data, 0, count );
}
fileOutputStream.flush();
fileOutputStream.close();
gzipInputStream.close();
The strange thing is that the exception is thrown for some files and sometimes it does not, but I can’t figure out why… 🙁
Am I missing something ?
Many thanks,
Advertisement
Answer
The error was due to a concurrent access to the file by another thread.