Republic Gadget, Windows Phone, Asansam box Version, Z3X BOX Samsung, How to Backup, iPhone 7 to PC/Mac, Korea Telecom

Java - Create Zip file in memory

Java - Create Zip file in memory - the world of technology is more advanced, we should be technically literate so as not left behind by others, in blogs Republic Gadget we will present updated information about technological developments, product reviews from various brands, now we will discuss first about this information Java - Create Zip file in memory we cover directly from reliable sources, 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();
}



so much information Java - Create Zip file in memory

hopefully the infromation that we show for you about Java - Create Zip file in memory can provide the latest knowledge about the gadgets you need in everyday life.

you've just read the article with the title Java - Create Zip file in memory if you intend to bookmark or share it for many people please use the link https://bhrepublicadominicana.blogspot.com/2008/04/java-create-zip-file-in-memory.html still a lot of information on this blog, please visit other pages.

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

Related : Java - Create Zip file in memory

0 komentar:

Post a Comment