Skip to content

Instantly share code, notes, and snippets.

@igrishaev
Last active July 31, 2023 09:57
Show Gist options
  • Save igrishaev/40b95ca99e859776daf61a8f045b5567 to your computer and use it in GitHub Desktop.
Save igrishaev/40b95ca99e859776daf61a8f045b5567 to your computer and use it in GitHub Desktop.
(defn gipz-encode ^bytes [^bytes input]
(let [in
(new ByteArrayInputStream input)
out-bytes
(new ByteArrayOutputStream)
out-gzip
(new GZIPOutputStream out-bytes true)
buf
(byte-array 1024)]
(loop []
(let [len (.read in buf)]
(when (> len 0)
(.write out-gzip buf 0 len)
(recur))))
(.toByteArray out-bytes)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment