Unzip Archive with Groovy

前端 未结 9 1208
深忆病人
深忆病人 2020-12-15 04:00

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 ?

9条回答
  •  一整个雨季
    2020-12-15 04:41

    def zip(String s){
        def targetStream = new ByteArrayOutputStream()
        def zipStream = new GZIPOutputStream(targetStream)
        zipStream.write(s.getBytes())
        zipStream.close()
        def zipped = targetStream.toByteArray()
        targetStream.close()
        return zipped.encodeBase64()
    }
    

提交回复
热议问题