File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting Zip file to bytearray and vice versa

 
Alpesh Rathod
Ranch Hand
Posts: 41
  • 0
  • 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??
 
Niv Tyagi
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Have you tried : java.util.zip.ZipInputStream

 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • 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.
 
mahavir swami
Greenhorn
Posts: 13
  • 0
  • 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

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic