How do I archive multiple files into a .zip file using scala?

后端 未结 6 1145
孤独总比滥情好
孤独总比滥情好 2020-12-14 19:41

Could anyone post a simple snippet that does this?

Files are text files, so compression would be nice rather than just archive the files.

I have the filename

6条回答
  •  离开以前
    2020-12-14 19:45

    I recently had to work with zip files too and found this very nice utility: https://github.com/zeroturnaround/zt-zip

    Here's an example of zipping all files inside a directory:

    import org.zeroturnaround.zip.ZipUtil
    ZipUtil.pack(new File("/tmp/demo"), new File("/tmp/demo.zip"))
    

    Very convenient.

提交回复
热议问题