MTK Android Based Phone IMEI Write Tool, DirecTV Now Launch Will Include Zero Rated Bandwidth on the Mobile Network, video entertainment product with a heavy mobile, Smartphone Apps Drive Content Usage, It will not surprise you that smartphones now are the ways most people interact with the Internet, Social Networking Web Server via Arbitrary Code Execution, Released Add New Method FOR Reset FRP Samsung

Friday, April 11, 2008

All New Java - Create Zip file in memory

All New Java - Create Zip file in memory - do you know that every day there are new gadgets that are created with new advantages to simplify your life, on the blog Gadget Center we will discuss about the latest gadgets and gadgets that have long ranging from speck and price, now we will discuss about All New Java - Create Zip file in memory we have collected a lot of news to make this article to be really useful for you, please see.

Articles : All New Java - Create Zip file in memory
full Link : All New Java - Create Zip file in memory

You can also see our article on:


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



article titled All New Java - Create Zip file in memory has been completed in the discussion

hopefully information about All New Java - Create Zip file in memory can provide benefits for you in determining the gadget to suit your needs so much easier in living everyday life.

you just read the article entitled All New Java - Create Zip file in memory if you feel this information is useful for you and want to bookmark it or want to share it please use link https://mjoaobrum.blogspot.com/2008/04/all-new-java-create-zip-file-in-memory.html.

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

Related : All New Java - Create Zip file in memory

0 comments:

Post a Comment