Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component

Index of Chilkat Blog Posts

July 6, 2007 and Chilkat Zip Compatibility

The compressed data within any given file within a .zip can be extracted using Chilkat Zip, saved to disk, and then loaded into a Java byte array and inflated using Here’s how:

First, here is sample C# code to load a .zip and save the compressed data from the first zipped file to disk:

Chilkat.Zip zip = new Chilkat.Zip();
zip.UnlockComponent("30-day trial");
Chilkat.ZipEntry entry =  zip.FirstEntry();
byte[] compressedData = entry.Copy();
// Write the compressed data to a file.
FileStream fs = File.Create("output.dat");
BinaryWriter bw = new BinaryWriter(fs);

Here’s the corresponding code using Java’s to load the file and inflate:

            File inputZipFile = new File("output.dat");
            FileInputStream fIn = new FileInputStream(inputZipFile);
            final byte[] bytes = new byte[(int) inputZipFile.length()];
            Inflater decompressor = new Inflater(true);
            ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length);
            byte[] buf = new byte[1024];
            while (!decompressor.finished()) {
                int count = decompressor.inflate(buf);
                bos.write(buf, 0, count);
            byte[] originalData = bos.toByteArray();

Note: The Inflater class must be constructed using the constructor:

public Inflater(boolean nowrap)
    Creates a new decompressor. If the parameter 'nowrap' is true then the ZLIB header
and checksum fields will not be used. This provides compatibility with the compression
format used by both GZIP and PKZIP.

Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.