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
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.