Maxtron News, Android KitKat, stock firmware, Flash file, Lava iris, Ulefone Tiger, Mobile App, Marketing Tool, Infinix Stock Roms, Android Multi Tools Latest Version

Java - Create Zip file in memory

Java - Create Zip file in memory - for a long time we built this blog Maxtron News with the intention to advance the knowledge of the community about technological developments that continue to advance, because not everyone can enjoy the technology, so you will we present the technology news according to what you need, now we will discuss first about Java - Create Zip file in memory please refer to the information we provide we feel quite complete because we summarize from reliable sources.

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 Java - Create Zip file in memory

hopefully the article that we make this Java - Create Zip file in memory can be useful for you in adding science about gadgets that continue to advance.

you just read the article with title Java - Create Zip file in memory if you wish to bookmark or share it please use link https://katieandmaxtron.blogspot.com/2008/04/java-create-zip-file-in-memory.html to get more information please visit our other blog page.

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

Related : Java - Create Zip file in memory

0 komentar:

Posting Komentar