Skip to content

Instantly share code, notes, and snippets.

@drewr
Created October 28, 2009 16:48
Show Gist options
  • Save drewr/220607 to your computer and use it in GitHub Desktop.
Save drewr/220607 to your computer and use it in GitHub Desktop.
(defn gzip-file
([path]
(gzip-file path ".gz"))
([path suffix]
(let [bufsize 8192
buf (make-array Byte/TYPE bufsize)]
(with-open [rdr (FileInputStream. (File. path))
wtr (GZIPOutputStream.
(FileOutputStream.
(format "%s%s" path suffix)))]
(loop [len (.read rdr buf)]
(when (pos? len)
(.write wtr buf 0 len)
(recur (.read rdr buf))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment