aspose file tools*
The moose likes I/O and Streams and the fly likes Creating spanned ZIP with Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Creating spanned ZIP with Java?" Watch "Creating spanned ZIP with Java?" New topic
Author

Creating spanned ZIP with Java?

Ruben Matthews
Greenhorn

Joined: Jan 05, 2009
Posts: 26
How would I create a spanned archive with Java, so that a large directory or file can be stored in chunks of a couple of Mbs? Is that possible with Java's ZIP API? I don't see any methods that offer this possibility.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18675
    
    8

I don't believe that there are any such methods. But on the other hand, people haven't been using spanned ZIP archives since floppy disks went out of fashion about five years ago. :-P
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Maybe not spanning ZIPs, but spanning archives (especially RAR) is still widely used. Not for floppies, but mostly for Usenet these days.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ruben Matthews
Greenhorn

Joined: Jan 05, 2009
Posts: 26
I don't think Java's ZIP API can do it unfortunately. I've been looking for other API's as well but without any luck. If there is anyone that knows an API that can do it I am very happy to hear it.
ZIP isn't absolutely necessary. Any other type of compression will do as long as I can create spanned archives from code.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

You can always invoke the zip program from the command line with Runtime.exec().


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Ruben Matthews
Greenhorn

Joined: Jan 05, 2009
Posts: 26
Hey Joe I see it's possible to split ZIP files with the Winzip interface, but I am not sure there is a command line argument for splitting files. I'm still looking into that. Using Winzip however, would make my program rely on Winzip, right? I prefer avoiding that.

Your suggestion did direct me to a different possible solution. Perhaps I could use Java to ZIP the entire contents of the folder and then use Java to split the ZIP file myself? Or is that for rocket scientists? I am not really familiar with the internals of files. Would it be possible to use Java to do something like this:

1. Read contents of directory and create ZIP (possible)
2. Open the file again in Java, but not with the ZIP API.
3. Read the file, and while reading, split the file into smaller bits of X Mb and save them (along with some code that defines the order)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18675
    
    8

You could certainly make a ZIP archive and then chop it into pieces with Java, no problem. That wouldn't be a spanned ZIP archive, because the pieces wouldn't be in the right format, but perhaps that isn't really a problem.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

As for WinZip and command line, WinZip has its own Command Line Support Add-on.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating spanned ZIP with Java?