wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes how to split a Zip file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "how to split a Zip file" Watch "how to split a Zip file" New topic
Author

how to split a Zip file

pavi
Ranch Hand

Joined: Jan 23, 2008
Posts: 31
I have ziped the files into a aa.zip file, If aa.zip file is bigger, for example, its size is bigger than 10MB, I want to split aa.zip into 5 files which is not bigger than 2MB . How do i need to do this?
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

I am not aware of any public API that will help you do that.
(Although if you do not want to do it programatically, there are utilities like WinSplitter that will do it)

I have not tried it but, every ZipEntry while using ZippedInput/OutputStream has a compressed size. You may get a rough estimate of the size of the zipped file while creating it. If you need 2MB of zipped files, then you can stop writing to a file after the cumulative size of entries become 1.9MB, taking .1MB for Manifest file and other zip file specific elements.

So, in a nutshell, you can write a wrapper over the ZippedInputStream as follows:



The above program is just a hint of the approach and not a final solution by any means.
[ June 10, 2008: Message edited by: Nitesh Kant ]

apigee, a better way to API!
 
 
subject: how to split a Zip file
 
Similar Threads
split big DOM xml file ??
splitting the big dom file ??
unix split command
Client side validation javascript showing up on the browser!!
how to read speific lines in a text file