Dan Mason
Dan Mason

Reputation: 121

gzuncompress data compressed by java.util.zip.InflaterInputStream

So I'm having trouble decompressing an array of numbers which where originally compressed by the java.util.zip.InflaterInputStream method in java.

I know I am doing something wrong, as the output after decompressing is similar to this (but a lot longer):

string '�������?�����!�A��������������������'

When reading the gzuncompress PHP documentation on the matter I see that it says:

"This function uncompress a compressed string."

I am totally misinterpreting the use of this function? or can it be used to decompress more than just a single string? I would really appreciate some help on this, as I don't feel like I am getting anywhere after some pretty deep searching on the subject.

Cheers

Upvotes: 2

Views: 512

Answers (1)

Stephen C
Stephen C

Reputation: 718788

I think you definitely are misinterpreting something:

java.util.zip.InflaterInputStream is a class not a method, and it is an uncompressor not a compressor. The javadoc says:

"This class implements a stream filter for uncompressing data in the "deflate" compression format."

If you are going to uncompress using gzuncompress at the PHP end, you need to compress using java.util.zip.GZIPOutputStream at the Java end.


If you are going to use java.util.zip.InflaterOutputStream to compress at the Java end, I think you need to use zlib.inflate at the PHP end to uncompress it - see http://php.net/manual/en/filters.compression.php

Upvotes: 3

Related Questions