(ns example.ByteInputStream (:gen-class :extends java.io.InputStream :state byteseq :init init :constructors {[clojure.lang.Seqable] []} :exposes-methods {read readSuper} :main false)) (defn -init [byte-seq] [[] (ref byte-seq)]) (defn -read ([this] (dosync (let [byte-seq (.byteseq this) [b & more-bytes] @byte-seq] (ref-set byte-seq more-bytes) (if b b -1)))) ([this byte-arr] (.readSuper this byte-arr)) ([this byte-arr off len] (.readSuper this byte-arr off len))) (comment (compile 'example.ByteInputStream) (def bis (example.ByteInputStream. [67 108 111 106 117 114 101])) (slurp bis) )