Zip & Unzip files in a scala like style
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 5 commits behind dbalduini:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



  import com.github.scalazip._

Writing Zips

Compressing a single File

val myFile = new"image.jpg")
val zip = myFile.zipAs("")

Creating a ZipArchive

val file1 = new"github1.jpg")
val file2 = new"github2.jpg")
val file3 = new"github3.jpg")
val files = file1 :: file2 :: file3 :: EmptyZip


val files = ZipArchive(file1, file2, file3)

To compress the ZipArchive, you can choose between zipAs or zipAtSource

// To Zip where you are running the JVM
val zip = myFile.zipAs("")

// To Zip at the source of the original head file
val zip = files.zipAtSource("")

Reading Zip Files

Uncompressing the file

  val zip = new CompressedFile("")
  val uncompressed = zip.unzipAtSource("images")

Reading Zip Files

  val zip = new CompressedFile("")
  val maybeFound = zip.find(e => e.getName endsWith ".txt")
  maybeFound match {
    case Some(lines) => lines.take(10) foreach println
    case None => println("No .txt file found")

All Togheter with implicit conversions

val file1 = new File("image1.jpg")
val file2 = new File("image2.jpg")
val file3 = new File("atextfile.txt")

val files = file1 :: file2 :: file3 :: EmptyZip

val zip = files.zipAs("")
val file = zip.unzipAs("stuff")



  • Ajust the Zip Reader
  • Work with encrypted zip files