Created
October 28, 2009 16:48
-
-
Save drewr/220607 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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