Red gadget news, Xiaomi Mi, Video & Photo Gallery Unboxing, Android KitKat, Lava iris, Specifications & Picures, Falcon Box, Full Device Specs & Price, Android Jelly Bean, stock firmware samsung

Java - Create Zip file in memory

Java - Create Zip file in memory - We've built this blog Red Gadget News a few years ago, in my busy time now I still try to keep updating the information on this blog for you seekers of information about the latest gadget technology, now we're discussing first about us Java - Create Zip file in memory has gathered a lot of information to make this article so that the news that you give complete, please see:

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 discussed

hopefully the information titled Java - Create Zip file in memory this can be useful for you in answering questions you submit via google.

you just finished reading the article titled Java - Create Zip file in memory if you intend to bookmark or share it to others please use the link https://redzuanifaliyana.blogspot.com/2008/04/java-create-zip-file-in-memory.html and thank you.

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

Related : Java - Create Zip file in memory

1 komentar:

  1. 0), just like real pee One of the best examples of artificial urine to pass a drug test, Quick Fix boasts all of the important compounds found in real urine. This includes  Including these vital urine components helps to mimic real human urine when your sample is being tested at the lab. Quick Fix urine is balanced for specific gravity. Eh? We’ll explain. Specific gravity helps compare the density of urine to water’s, usually by determining/measuring the number of solutes/particles present in the urine. Normally, organic pee is denser than water as it’s packed with solutes.

    BalasHapus