Techno News, Nexus Lollipop Upgrade, WiFi Adapter, Transfer Photos from LG from Phone, Samsung Galaxy, Stock Firmwares, Huawei Android, Linux

Jumat, 11 April 2008

Java - Create Zip file in memory

Java - Create Zip file in memory - very many people who love gadgets, especially gadgets nowadays with all sophisticated spek good, but not all gadgets suitable for your purposes, in blogs Techno News we will review and display speck with price gadgets from various brands and news about gadgets latest, now we will discuss first about Java - Create Zip file in memory please in see until finished because the news that we convey we try to complete for you.

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



enough already information Java - Create Zip file in memory

hopefully information about Java - Create Zip file in memory that we provide can be useful for you in determining the appropriate gadgets with your needs.

you just read the article with title Java - Create Zip file in memory if you intend to bookmark or share it please use link https://nikephang.blogspot.com/2008/04/java-create-zip-file-in-memory.html if you need other information about software or other hardware please visit other page in this blog.

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

Related : Java - Create Zip file in memory

0 komentar:

Posting Komentar