Skip to content

Instantly share code, notes, and snippets.

@mknoszlig
Created December 6, 2011 17:11
Show Gist options
  • Save mknoszlig/1438992 to your computer and use it in GitHub Desktop.
Save mknoszlig/1438992 to your computer and use it in GitHub Desktop.
(defn read-bytes [is n]
(let [buf (make-array Byte/TYPE n)]
(loop [to-read n]
(let [bytes-read (.read is buf (- (count buf) to-read) to-read)]
(if (> to-read bytes-read 0)
(recur (- (count buf) bytes-read))
(seq buf))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment