This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Zipping a file with java api without storing full path Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Zipping a file with java api without storing full path" Watch "Zipping a file with java api without storing full path" New topic
Author

Zipping a file with java api without storing full path

Nicol�s Pad�n
Greenhorn

Joined: Jan 13, 2006
Posts: 7
Hello,

Is it possibly to zip a file with the java api without storing the full path of the file being zipped? The winrar GUI has an option to do it, I want to get the same result but inside a java app.

Thank you very much in advance...

Nicol�s
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

ZipOutputStream takes an OutputStream in the constructor.
So, you can create the ZipOutputStream over a ByteArrayOutputStream and keep writing.
ByteArrayOutputStream will have the zipped data and you need not write it anywhere on the file system and hence do not need any path.

Does this answer your question?


apigee, a better way to API!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

ZipEntry can have any name set when you create it. Play around with that.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Zipping a file with java api without storing full path
 
Similar Threads
how to handle file uploads in spring
Zipping a file with java api without storing full path
file searching with file name in a specific root directory
Struts upload without the StrutsUploadForm
Zipping a file with java api without storing full path