Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(import '( InputStream Reader))
(def buffer-size 8192)
(defn byte-seq [^InputStream input-stream]
(let [buffer (make-array Byte/TYPE buffer-size)
size (.read input-stream buffer)]
(when-not (= size -1)
(lazy-cat (take size buffer)
(byte-seq input-stream))))))
(defn char-seq [^Reader reader]
(let [buffer (make-array Character/TYPE buffer-size)
size (.read reader buffer)]
(when-not (= size -1)
(lazy-cat (take size buffer)
(char-seq reader))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.