aspose file tools*
The moose likes I/O and Streams and the fly likes zip files without path info... 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 "zip files without path info..." Watch "zip files without path info..." New topic
Author

zip files without path info...

Eric Martin
Greenhorn

Joined: Jul 15, 2005
Posts: 22
I don't know if this is the best board for the question, but I am trying to do this from a servlet, so...

I am using ZipOutputStream to create zip file containing 3 files on our server. I don't want to files to be inside directories when they are zipped, so how do I add them without the path information?



The 3 filenames all include the full server path to the file and they are getting added to the archive inside a directory structure that matches the server path.

TIA.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61002
    
  65

Moved to the I/O forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rajagopal Manohar
Ranch Hand

Joined: Nov 26, 2004
Posts: 183
just guessing

try changing

// Add ZIP entry to output stream.
zos.putNextEntry(new ZipEntry(filenames[i]));


to

Eric Martin
Greenhorn

Joined: Jul 15, 2005
Posts: 22
Thanks! I was able to get it working with the following changes:



The ZipEntry is what controls how it is represented in the zip file.

-Eric
[ December 13, 2005: Message edited by: Eric Martin ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: zip files without path info...