Compressing byte arrays using GZIP in java

Viewed 3822

I've been working on a function that compresses an array of bytes using GZIP and sends it through an outputStream that belongs to a socket. It downloads fine but when trying to decompress on my PC it says that file is corrupted.

private void Zip(byte[] datatocompress)
    {
            ZipOutputStream zippoutstream = new ZipOutputStream(outputstream);

            zippoutstream.putNextEntry(new ZipEntry("file.html"));
            zippoutstream.write(datatocompress);
            zippoutstream.closeEntry();
            zippoutstream.flush();
            zippoutstream.close();
    }

No idea about what crashes. Any suggestion?

1 Answers
Related