Java - Create Zip file in memory

Java - Create Zip file in memory - is the information you are looking for, and in the blog Google News we have provided her, all right in this article titled Java - Create Zip file in memory we will discuss it in full, in addition to the information we have also provided a lot of info about the latest gadgets and a wide range of tips and tricks that according to the gadget you are using, well please continue reading:

Penyanyi : Java - Create Zip file in memory
Judul lagu : 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();
}



Demikianlah Artikel Java - Create Zip file in memory

Sekian Kunci gitar Java - Create Zip file in memory, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sekian postingan Chord gitar lagu kali ini.

Anda sedang membaca artikel Java - Create Zip file in memory dan artikel ini url permalinknya adalah https://googledoodlenewstoday.blogspot.com/2008/04/java-create-zip-file-in-memory.html Semoga artikel ini bisa bermanfaat.

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

Related : Java - Create Zip file in memory

1 komentar:

  1. Lemon Juice & WaterLemon has been our age-old quick fix for various issues that we encounter on an everyday basis. Lemon juice is an acidic drink that can aid in naturally cleansing your body of toxins.For best results, cut a lemon in half and squeeze it into a cup of water. This concoction of citric acid and water will quickly let your body get rid of the toxins.You can repeat this method as many times as you would like. This diluted lemon juice can be consumed multiple times on the days leading up to the test and will ensure that no residual toxins are retained by your system. Visit: https://www.urineworld.com/

    BalasHapus