java extract zip Unexpected end of ZLIB input stream
<p>I am creating a program that will extract a zip and then insert the files into a database, every so often I get the error </p>

<pre><code>java.lang.Exception: java.io.EOFException: Unexpected end of ZLIB input stream
</code></pre>

<p>I can not pinpoint the reason for this as the extraction code is pretty much the same as all the other code you can find on the web. My code is as follows: </p>

<pre><code>public void extract(String zipName, InputStream content) throws Exception {

    int BUFFER = 2048;

    //create the zipinputstream 
    ZipInputStream zis = new ZipInputStream(content);

    //Get the name of the zip
    String containerName = zipName;

    //container for the zip entry
    ZipEntry entry;

    // Process each entry
    while ((entry = zis.getNextEntry()) != null) {

        //get the entry file name
        String currentEntry = entry.getName();

        try {

                ByteArrayOutputStream baos = new ByteArrayOutputStream();

                // establish buffer for writing file
                byte data[] = new byte[BUFFER];
                int currentByte;

                // read and write until last byte is encountered
                while ((currentByte = zis.read(data, 0, BUFFER)) != -1) {

                    baos.write(data, 0, currentByte);
                }

                baos.flush(); //flush the buffer 

                //this method inserts the file into the database
                insertZipEntry(baos.toByteArray());

                baos.close();

        } 
        catch (Exception e) {
            System.out.println("ERROR WITHIN ZIP " + containerName);
        }
    }
}
</code></pre>
