Unexpected end of ZLIB input stream

I believe it's to do with the "no-wrap" option which you're passing "true" for in both the Deflater and Inflater. Setting both of these to false fixes the problem - although I'd recommend setting the string encoding in both places to (e.g. to UTF-8) instead of using the system default encoding.

The docs for "nowrap" are fairly vague, but they state:

Note: When using the 'nowrap' option it is also necessary to provide an extra "dummy" byte as input. This is required by the ZLIB native library in order to support certain optimizations.

Presumably this dummy input byte is missing, although it doesn't explain where it should go...


I had this problem and it was because i wasn't correctly closing my output streams.

Tags:

Java

Deflate