ZipException creating zip file
I am trying to modify a zip file, by creating a new zip file and copying the entries over selectively. I use the following code:
try
{
zipFile = new ZipFile(args[0]);
zos = new ZipOutputStream(new FileOutputStream(args[1]));
entries = zipFile.entries();
while(entries.hasMoreElements())
{
entry = (ZipEntry)entries.nextElement();
if (entry.getName().endsWith(".class") || entry.isDirectory() ||
entry.getName().endsWith(".MF"))
{
zos.putNextEntry(entry);
}
}
zipFile.close();
zos.close();
}
catch (IOException ioe)
{
System.err.println("Unhandled exception:");
ioe.printStackTrace();
System.err.println(entry);
return;
}
However it throws an exception for the second entry that it encounters:
invalid entry size (expected 10804 but got 0 bytes)
at java.util.zip.ZipOutputStream.closeEntry(Unknown Source)
at java.util.zip.ZipOutputStream.putNextEntry(Unknown Source)
at delPNGsFromJar.main(delPNGsFromJar.java:34)
It doesn't matter which entry it is, it always fails on the seconds.
Anyone have any ideas?

