I am having a requirement wherein i have to create a zip file from a list of available files. The files are of different types like txt,pdf,xml etc.I am using java util clas
Wrap your ZipOutputStream into a personalized OutputStream, named here YourOutputStream.
public YourOutputStream(ZipOutputStream zos, int maxSizeInBytes)YourOutputStream, it will first write it on zos2public void writeFile(File file) throws ZipFileFullExceptionpublic void writeFile(String path) throws ZipFileFullExceptionmaxSizeInBytes
You need two ZipOutputStream, one to be written on your drive, one to check if your contents is over 5MB.
EDIT : In fact I checked, you can't remove a ZipEntry easily.
http://download.oracle.com/javase/6/docs/api/java/io/ByteArrayOutputStream.html#size()