Filtered extraction from zip file using ZipInputStream and Java 8

By dave on May 16, 2015

In the example below we build on the Reading a zip file from java using ZipInputStream page to provide basic filtering. This filtering is provided by the filteredExpandZipFile method taking a Predicate. Every ZipEntry is passed to the predicate, but only ones that match (predicate returns true) are included. Note that the size of an entry cannot be accurately determined in all cases, so it is not safe to perform validation on the this field.

Writing a zip file in java using ZipOutputStream.

By dave on April 27, 2015

Following on from one of our popular articles on Reading a zip file from java using ZipInputStream we’ve put together a new article on how to create a zip archive using Java. The below example uses ZipOutputStream to create a zip file from all the items in a directory. Zip files are written slightly differently to a normal stream in that each entry is put into the stream one at a time.

Reading a GZIP file using Java

By dave on July 1, 2012

Another common compression file format on Linux is the GZIP format. Java again has out of the box support for this file format. Gzip files differ from zip files in that they only contain one file, the compressed form of the original file with a .gz extension. Java’s GZipInputStream takes such a file type and decompresses it. We can treat GZipInputStream directly like a FileInputStream. Here is an example that expands such a file to disk

Reading a zip file from java using ZipInputStream

By dave on July 1, 2012

Java provides support for reading zip files in the form of ZipInputStream. This class provides an API where you can iterate over all the items in a given zip file, reading the data from the archive for each file. In order to do this, first you must create the ZipInputStream instance giving the file that you wish to expand. Then you iterate using the getNextEntry method on the stream, which returns the header data for each entry in turn.

tcMenu for Arduino

This site uses cookies to analyse traffic, and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.

Send a message

Please use the forum for help with UI & libraries.

This message will be securely transmitted to our servers.