Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unzip Archive with Groovy

is there a built-in support in Groovy to handle Zip files (the groovy way)?

Or do i have to use Java's java.util.zip.ZipFile to process Zip files in Groovy ?

like image 234
HaBaLeS Avatar asked Mar 14 '09 12:03

HaBaLeS


1 Answers

Maybe Groovy doesn't have 'native' support for zip files, but it is still pretty trivial to work with them.

I'm working with zip files and the following is some of the logic I'm using:

def zipFile = new java.util.zip.ZipFile(new File('some.zip'))  zipFile.entries().each {    println zipFile.getInputStream(it).text } 

You can add additional logic using a findAll method:

def zipFile = new java.util.zip.ZipFile(new File('some.zip'))  zipFile.entries().findAll { !it.directory }.each {    println zipFile.getInputStream(it).text } 
like image 55
Chad Gorshing Avatar answered Oct 04 '22 16:10

Chad Gorshing