Austin Gadget, Samsung Galaxy, Android Jelly Bean, stock firmware, Volcano Box, miracle box, Internet Access, huawei, How to Backup Data, iPhone 7 to PC/Mac and ZTE

Java - Create Zip file in memory

Java - Create Zip file in memory - We have long been building this blog, we are trying to present a complete and reliable information. ranging from hardware products to software that develops to facilitate your life, but as the gadget's increasingly sophisticated capabilities are increasingly also the menu that you must understand, in the blog Austin Gadget we will review many gadget products from start speck and price, we will discuss first about Java - Create Zip file in memory hopefully information will give will give answer to your question to google, please refer to.

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



so many information about Java - Create Zip file in memory

hopefully the information we provide about Java - Create Zip file in memory can be useful for you and the readers of all readers of this blog.

you just finished reading the article with the title Java - Create Zip file in memory if you intend to bookmark or share please use the link https://austinangck2809.blogspot.com/2008/04/java-create-zip-file-in-memory.html and if you want to get other information please visit other pages on this blog.

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

Related : Java - Create Zip file in memory

0 comments:

Posting Komentar