I'm struggling with how to gzip/gunzip byte arrays from clojure. I don't
really get how clojure.java.io streams supposed to be used.
This appears to gzip a string:
(let [baos (java.io.ByteArrayOutputStream.)
gzos (java.util.zip.GZIPOutputStream. baos)]
(.write gzos (.getBytes "foo"))
(.finish gzos)
(.toByteArray baos))
and I can expand on this to gunzip the string afterwards:
(let [baos (java.io.ByteArrayOutputStream.)
gzos (java.util.zip.GZIPOutputStream. baos)]
(.write gzos (.getBytes "foo"))
(.finish gzos)
(let [gzbytes (.toByteArray baos)
bais (java.io.ByteArrayInputStream. gzbytes)
gzis (java.util.zip.GZIPInputStream. bais)]
(slurp gzis)))
But slurp builds strings. I need to do this with byte arrays. Do I have to
rewrite slurp to build a byte array? Is there any simpler way to do this?
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.