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();
}
Hi! I really like your content. Your post is really informative. I have learned a lot from your article and I’m looking forward to apply it.
BalasHapusignou solved assignment
ms 100 ignou
nice post
BalasHapusBeatspice Musicnice post
Beatspice Music
CROWNQQ I AGEN BANDARQ I BANDARQ ONLINE I ADUQ ONLINE I DOMINOQQ TERBAIK
BalasHapusYuk Buruan ikutan bermain di website CrownQQ
Sekarang CROWNQQ Memiliki Game terbaru Dan Ternama loh...
9 permainan :
=> Poker
=> Bandar Poker
=> Domino99
=> BandarQ
=> AduQ
=> Sakong
=> Capsa Susun
=> Bandar 66
=> Perang Baccarat (NEW GAME)
=> Bonus Refferal 20%
=> Bonus Turn Over 0,5%
=> Minimal Depo 20.000
=> Minimal WD 20.000
=> 100% Member Asli
=> Pelayanan DP & WD 24 jam
=> Livechat Kami 24 Jam Online
=> Bisa Dimainkan Di Hp Android0619679319
=> Di Layani Dengan 5 Bank Terbaik
=> 1 User ID 9 Permainan Menarik
Ayo gabung sekarang juga hanya dengan
mengklick CrownQQ
Link Resmi CrownQQ:
ratuajaib.com
ratuajaib.net
ratuajaib.info
BACA JUGA BLOGSPORT KAMI:
Agen BandarQ Terbaik
Winner CrownQQ
Daftar CrownQQ
Agen Poker Online
Info Lebih lanjut Kunjungi :
WHATSAPP : +855882357563
Line : CS CROWNQQ
Facebook : CrownQQ Official
Such A Nice Article i Loved it A Lot I Have read your more Articles Keep It Up Think so you Maintain Your Lead In Future.Mrpendus
BalasHapusPotrzebujesz wypożyczyć samochód osobowy na Mazurach w Olsztynie, Kętrzynie, Giżycku, Mrągowie, Bartoszycach, Węgorzewie, Orzyszu, Ełku, to świetnie trafiłeś. Najtańsza wypożyczalnia samochodów wynajem aut!
BalasHapusVery good article! Your post is really helpful for me thanks for wonderful post.I am very happy to read your post SSC Result 2020 has been Published First Check Your Result With Full Marksheet
BalasHapusEducation Board Dhaka Board SSC Result 2020 has been Published Check Your Result Download the Marksheet
What a Beautiful post! This is so chock full of useful information I can't wait to dig and start using my time on blogging. I am just over six month into blogging , I newly wrote an article Best Immune Booster Fitspire product makes immune stronger & healthier to fight against corona
BalasHapusWhat a Beautiful post! This is so chock full of useful information I can't wait to dig and start using my time on blogging. I am just over six month into blogging , I newly wrote an article Best Immune Booster Fitspire product makes immune stronger & healthier to fight against corona
BalasHapusWhat a Beautiful post! This is so chock full of useful information I can't wait to dig and start using my time on blogging. I am just over six month into blogging , I newly wrote an article Best Immune Booster Fitspire product makes immune stronger & healthier to fight against corona
BalasHapus
BalasHapusThat is nice article from you , this is informative stuff . Hope more articles from you . I also want to share some information about devops online course and devops training videos
This content was really helpful. The way you arranged every detail you gave was super cool.
BalasHapus“Find daily opportunities to apply what you have jobs plus” Only this made my year.
Thanks for sharing! you can also apply online recruitment
jobs
Recruitment
Job Past Qustions
Contact Us
Nice Article
BalasHapusPlay and win in
SahabatQQ
Agen Domino99
Pretty! This was a really wonderful post. Thank you for providing these details.
BalasHapushttp://www.easybuilder.pro/PRICES
What a Beautiful post!
BalasHapusWhat a Beautiful post!
viapk
تحميل تحديث الواتساب الذهبي 2022 احدث اصدار
BalasHapusrental insurance
BalasHapus