I'm a bit confused. I know that an empty zip is not legal. But what about this sample snippet:
ZipOutputStream zos = null;
try
{
zos = new ZipOutputStream(new FileOutputStream("..."));
//
//..
//
}
finally
{
zos.close();
}
If no zip entries had been added for some reason (possibly exceptional situation) then the following exception will be thrown on close attempt:
Exception in thread "main" java.util.zip.ZipException: ZIP file must have at least one entry
at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:304)
at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:146)
at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:321)
In this situation what would be the cleanest way to close the stream?
Thanks...