wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes Converting Zip file to bytearray and vice versa Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Converting Zip file to bytearray and vice versa" Watch "Converting Zip file to bytearray and vice versa" New topic
Author

Converting Zip file to bytearray and vice versa

Alpesh Rathod
Ranch Hand

Joined: Jan 06, 2009
Posts: 41
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??


Thanks,
Alps
Niv Tyagi
Greenhorn

Joined: Oct 14, 2009
Posts: 21

Have you tried : java.util.zip.ZipInputStream

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19685
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
mahavir swami
Greenhorn

Joined: Sep 18, 2009
Posts: 13


so this will convert your zip entry into byte array

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting Zip file to bytearray and vice versa