Skip to content

dbalduini/scala-zip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scala-zip

Example

  import com.github.scalazip._

Writing Zips

Compressing a single File

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

Creating a ZipArchive

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

Or

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("images.zip")

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

Reading Zip Files

Uncompressing the file

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

Reading Zip Files

  val zip = new CompressedFile("datasource.zip")
  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 Together 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("stuff.zip")
val file = zip.unzipAs("stuff")

================

TODO

  • Ajust the Zip Reader
  • Work with encrypted zip files

About

Zip & Unzip files in a scala like style

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages