This is how I did it. Once you finish downloading the zip fie from a url and you get a byte[] array out of it, simply pass it to a ByteArrayInputStream and pass that input stream to a ZipInputStream.

Check out the code:

In a zip file, every file or folder is represented by a ZipEntry. To browse through the zip file’s contents, loop the ZipInputStream and call getNextEntry() which returns a ZipEntry object.

To get the input stream of the file, just use the same ZipInputStream object. The developers did a slick job of designing this class.

Check out the code:

What the code does is that when getNextEntry() is called, it will go to the first file (or folder) in the list. The code assumes that there is only one file in the zip file and it reads the content of the file without having to save it.

You have to add code such as doing a check if the ZipEntry is a file or folder in case you have different file types in your zip file.

zipThe ZIP compression file format has been quite common in the computing world today. It is even incorporated within Mac OS itself. Back when storage space was small, compression was mainly used to group tons of files and divided into smaller files to fit into diskettes. Now, compression is mainly used to group files together as one file. You can zip files in Mac OS either using the UI or through the command line. This neat article Create ZIP Archives in Mac OS X has some great tips and insights when doing zip compression in Mac OS. When using zip compression, Mac OS X file elements are retained if encoded and decoded using the correct tools. Compression can save storage and bandwidth (when sending or downloading files in the internet). The zip format can be decoded on nearly any system which means compressing it in zip format can always be read in other systems that support the file format for compressing and decompressing files.

Zip compression in Mac OS has some cons of its own. The Finder does not support the creation of encrypted archives. What it is capable of, is only the standard compression. There are no file checksums to verify content as well and the Finder does not support modifying existing archives. Still, despite these cons, the zip compression in Mac OS provides users a quick and nifty tool to compress groups of files together quickly and easily.

Related Posts Plugin for WordPress, Blogger...