This week's book giveaway is in the Security forum.
We're giving away four copies of Securing DevOps and have Julien Vehent on-line!
See this thread for details.
Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting Zip file to bytearray and vice versa  RSS feed

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I want to convert a zip file to byte array and then use that byte array to create a new zip file??

Please anyone how do i do it??
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Have you tried : java.util.zip.ZipInputStream

 
Sheriff
Posts: 21256
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ZIP file does not need to be unzipped, so ZipInputStream is not necessary.

Use a FileInputStream to read the ZIP file and a ByteArrayOutputStream to write its contents to. Get the latter's byte[]. Use ByteArrayInputStream and FileOutputStream to reverse the process.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


so this will convert your zip entry into byte array

now you want this byte array gain to be written in zip so

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!