Skip to content

Instantly share code, notes, and snippets.

@AeroNotix
Created January 24, 2014 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AeroNotix/eecf8d63aa307381bfff to your computer and use it in GitHub Desktop.
Save AeroNotix/eecf8d63aa307381bfff to your computer and use it in GitHub Desktop.
(defn split-byte-array [ba c]
(let [bit (conv/ubyte (first (.getBytes c)))]
(loop [bais (ByteArrayInputStream. ba)
curr []
out []]
(let [c (.read bais)]
(if (= -1 c)
(conj out (int-seq-to-byte-array curr))
(if (= c bit)
(recur bais [] (if (> (count curr) 0)
(conj out (int-seq-to-byte-array curr))
out))
(recur bais (conj curr c) out)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment