Created
December 6, 2011 17:11
-
-
Save mknoszlig/1438992 to your computer and use it in GitHub Desktop.
This file contains 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
(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