Skip to content

Instantly share code, notes, and snippets.

@choffstein
Created February 29, 2012 18:12
Show Gist options
  • Save choffstein/1943113 to your computer and use it in GitHub Desktop.
Save choffstein/1943113 to your computer and use it in GitHub Desktop.
GZIP A string
;; zip a string
(def s "aslgajskghkajsghkjasgjhajsghjags")
(def ostream (java.io.ByteArrayOutputStream.))
(def gzip_ostream (java.util.zip.GZIPOutputStream. ostream))
(clojure.java.io/copy s gzip_ostream)
(.close gzip_ostream)
(def bytes (java.io.ByteArrayInputStream. (.toByteArray ostream)))
(def gzip_istream (java.util.zip.GZIPInputStream. bytes))
(slurp gzip_istream)
(.close gzip_istream)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment