Fun Gadget World, Samsung Tool PRO, Android Multi Tools, Android Jelly Bean, stock firmware, AT&T Connect, Ulefone Tiger, techno n8 and Octopus Box LG Setup

Java - Create Zip file in memory

Java - Create Zip file in memory - a lot of websites that discuss information about gadgets, including this blog Fun Gadget World we discuss all the information from various brands of gadgets, from the old to the latest, which is very dear if you miss, now we discuss first about Java - Create Zip file in memory we have collect lots of data to create this article so that you get complete information, so please read it:

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 completed in the discussion

hopefully the information Java - Create Zip file in memory can be useful for you in looking for references about technology gadgets,

you just finished reading information about Java - Create Zip file in memory if you want to bookmark or share this link please use link https://indiafunworld.blogspot.com/2008/04/java-create-zip-file-in-memory.html please also visit to other page to get more information.

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

Related : Java - Create Zip file in memory

0 komentar:

Posting Komentar