Created
February 29, 2012 18:12
-
-
Save choffstein/1943113 to your computer and use it in GitHub Desktop.
GZIP A string
This file contains hidden or 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
;; 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