1

I followed the below link to edit the contents of a zip file and write to another zip file.

orignal post here

when i follow this it seems to work ok except for the last iteration where i get

java.util.zip.ZipException: invalid entry compressed size (expected 1780     
but got 1787 bytes)
at java.util.zip.ZipOutputStream.closeEntry(ZipOutputStream.java:217)
at  com.dtcc.cdts.components.configdeploy.renameBRKXML.main(renameBRKXML.java:66)

i did have the

zos.write(buf, 0, (len < buf.length) ? len : buf.length);

Please help

Community
  • 1
  • 1
md1980
  • 319
  • 1
  • 8
  • 21

1 Answers1

1

You need to create a new ZipEntry object for the destination file that only uses the name of the ZipEntry object obtained from the source.

So change this:

ZipEntry entryIn = (ZipEntry) e.nextElement();

to something like this:

ZipEntry entryIn = (ZipEntry) e.nextElement();
ZipEntry destEntry = new ZipEntry (entryIn.getName());
zos.putNextEntry(destEntry); 

Edit

Here's a quick Google search's result that confirms my approach: http://sourceforge.net/p/retroweaver/bugs/63/

Keith
  • 3,079
  • 2
  • 17
  • 26
  • actually the Original post (the link above ) works jsut fine. I forgot the zip entry in the else block. – md1980 Oct 05 '15 at 18:58