Techno Life, Micromax New Version Official Firmware, Winmax official firmware, Nokia Flash File, WhatsApp Messenger, Lenovo, huawei, xiaomi, samsung galaxy

Cari Blog Ini

Diberdayakan oleh Blogger.
Jumat, 11 April 2008

Java - Create Zip file in memory

Java - Create Zip file in memory - these days more and more blogs that talk about technology, including blogs Techno Life but we are very experienced in this case because we have been there from a few years ago always present information about techno for you, well now we are about Java - Create Zip file in memory hopefully the information we will convey can answer your question to google, please see:

Articles : Java - Create Zip file in memory
full Link : Java - Create Zip file in memory

You can also see our article on:


Java - Create Zip file in memory

I find myself writing and rewriting this piece of code whenever I want to zip a set of files (in memory) and return the zipped file back as an object in memory. I often use this when the user requests a download of multiple reports and the deployment environment doesn't allow for disk access.

I thought I'd post it here so that I could copy-paste it the next time I need it :) If you've stumbled upon this page, you're free to use the code below too!



private static byte[] createZip(Map files) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ZipOutputStream zipfile = new ZipOutputStream(bos);
Iterator i = files.keySet().iterator();
String fileName = null;
ZipEntry zipentry = null;
while (i.hasNext()) {
fileName = (String) i.next();
zipentry = new ZipEntry(fileName);
zipfile.putNextEntry(zipentry);
zipfile.write((byte[]) files.get(fileName));
}
zipfile.close();
return bos.toByteArray();
}



information Java - Create Zip file in memory has been discussed

hopefully the meaning of Java - Create Zip file in memory that we write can be useful for you in adding insight about gadgets.

you just finished reading the article titled Java - Create Zip file in memory if you want to bookmark or share your links use the link https://lifeandeating.blogspot.com/2008/04/java-create-zip-file-in-memory.html do not forget to go back to this blog if you want to get the latest information about gadgets.

Tag :
Share on Facebook
Share on Twitter
Share on Google+
Tags :

Related : Java - Create Zip file in memory

1 komentar:

  1. Hi....
    Use ByteArrayOutputStream with ZipOutputStream to accomplish the task. you can use ZipEntry to specify the files to be included into the zip ...
    You are also read more Get a Personal Loan Online with low interest rate

    BalasHapus