I'm creating a zip file using the java.util.zip package. The created zip file has to be spilt, if it exceeds a size limit. How can I do this splitting of the file?

Tim Rohaly

Java has no built-in support for disk or file spanning. However, it should be easy to do this on your own. I would suggest subclassing FileOutputStream to perform checks on the length of the data written so far, and if the data approaches the maximum allowed, close the underlying file and open a new one for writing. You will then be able to use your subclass with any of the standard output streams, including ZipOutputStream.

Also, from Luigi Viggiano:
The directory list of a zip file is located at bottom of the file, that's why zip tools ask for last disk of the set before to unpack. In a spanneable archive format this is really uncomfortable, and it can be deduced that, zip format itself, doesn't complain spanning. Maybe WinZip and other tools, handles zip spanning simply cutting the output file. And this should be done also in Java to implement spanning.