Possible Duplicate:
In Java: How to zip file from byte[] array?
Here’s the deal, I work at a university web office and we provide a few website templates for university departments and clubs. I have been tasked with building a web form that will allow them to select the template they want and provide a title which will be programmatically inserted into the template they select before downloading.
My question is, can I pull the template into memory, insert the title and output it to a zip archive without writing a temporary file to disk?
It seems that Java’s ZipEntry requires a filename and cannot simply use data already in memory.
No, the name “file name” is probably a little bit confusing here but it means the file name of entry in ZIP archive you are creating. Take a look on ZipOutputStream. It is created as a wrapper over every other output stream, either
FileOutputStreamorByteArrayOutputStream. UsingByteArrayOutputStreamyou can create zip archive completely in memory.