title: Java ZipInputStream closes after reading ZipEntry of image
body: <p>We are trying to modify one of the XML files in 2007 MS Excel. For this, the xlsx file is being unzipped using Java's ZipInputStream and then copied to a new Zip file using ZipOutputStream. The code snippets are as below :</p>
  
  <pre><code>        FileInputStream fis = new FileInputStream("C:\\_132139TRD-GDR_Conversion.xlsx");
          ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
  
          FileOutputStream fos =  new FileOutputStream("C:\\_132139TRD-GDR_Conversion123.xlsx");
          ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos));
  
          while ((entry = zis.getNextEntry()) != null) {
  
              System.out.println("Processing Entry : " + entry.getName());
              System.out.println("Processing Entry Size : " + entry.getSize());
              System.out.println("Entry Available : " + zis.available());
  
          if(entry.getName().equals(ZIP_ENTRY_WOOKBOOK_XML)){
            //Process XML
          }
  
          ZipEntry ze = new ZipEntry(entry.getName());
              zos.putNextEntry(ze);
              if(entry.getName().equals(ZIP_ENTRY_WOOKBOOK_XML)){
                      zos.write(XML.getBytes());
              }else{
                  ByteArrayOutputStream stream = new ByteArrayOutputStream();
                  while ((count = zis.read(data, 0, BUFFER)) != -1) {
                      stream.write(data, 0, count);
                  }
                  tempBuffer = stream.toByteArray();
                  zos.write(tempBuffer);
              }
              zos.closeEntry();               
          }
          zos.close();
          fos.close();
          zis.close();
          fis.close();
  </code></pre>
  
  <p>In this snippet, after we encounter a JPEG file, the "entry = zis.getNextEntry()" returns null. We are not able to read the next ZipEntry - which leads to an incomplete Excel. The output for a sample Excel file is as below :</p>
  
  <pre><code>Start Date Mon Dec 06 15:33:33 IST 2010
  Processing Entry : xl/media/Logo2005_JPM_A_Black_170x50.jpeg
  Processing Entry Size : -1
  Entry Available : 1
  End Date Mon Dec 06 15:34:58 IST 2010
  </code></pre>
  
  <p>The ZipInputStream gets closed as soon as the JPEG file is copied. (entryEOF and reachEOF variables both turn true and entry is null after copying the image).</p>
  
  <p>Has anybody faced a similar issue ? Is it a bug that reachEOF also turns true after copying the file ?</p>
  
  <p>Midhun.</p>