drewr (owner)

Revisions

  • 0862a3 drewr Wed Oct 28 10:28:09 -0700 2009
  • 1486c2 drewr Wed Oct 28 10:16:37 -0700 2009
  • d0ad86 drewr Wed Oct 28 09:48:38 -0700 2009
gist: 220607 Download_button fork
public
Public Clone URL: git://gist.github.com/220607.git
Embed All Files: show embed
gzip_file.clj #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(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))))))))