Tecno Mobile Phones, Huawei, Firmware Flash File, Android Jelly Bean, Facebook Page, iPhone Apple, Symphony Firmware, Lava iris, samsung

Java - Create Zip file in memory

Java - Create Zip file in memory - technological developments continue to grow rapidly, old technologist replaced with the latest, on the blog Tecno Mobile Phones we will discuss various updated technology from various brands around the world, well now we will discuss first about Java - Create Zip file in memory we collect a lot data from various reliable sources to make this article, 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();
}



just so much information about Java - Create Zip file in memory

hopefully Java - Create Zip file in memory information can provide benefits for you in adding insight about the latest gadget technology

you just read the article about Java - Create Zip file in memory and can you bookmark or share with link https://ghchjgv.blogspot.com/2008/04/java-create-zip-file-in-memory.html so thank you.

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

Related : Java - Create Zip file in memory

0 komentar:

Post a Comment