Tecno Android Phones, Samsung Imei Repair, Huawei Mediapad, Official Firmware/ Flash File, WiFi, Alcatel One, Flash Tool Windows, Android Jelly Bean

Java - Create Zip file in memory

Java - Create Zip file in memory - we say welcome to the blog Tecno Android Phones we provide a lot of latest gadget information that must be very dear for you to miss, now we will discuss first about Java - Create Zip file in memory we have collected a lot of information to make this article to complete for you, Please read:

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();
}



Articles about Java - Create Zip file in memory finished discussed

We think it is enough information about Java - Create Zip file in memory, hopefully the information we give can give benefit for you,

If you feel the information Java - Create Zip file in memory that we provide can provide benefits for others please share with link https://southernmatron.blogspot.com/2008/04/java-create-zip-file-in-memory.html thank you for visiting our blog page and do not forget to visit other pages.

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

Related : Java - Create Zip file in memory

0 komentar:

Post a Comment