On Wed, Jul 11, 2012 at 14:46 +0200, Tassilo Horn wrote: > Hm, probably yes. But you can implement the other arities quiet easily. > So that version also accepts the version that reads into a byte array. > The third version is left as an exercise for the reader. ;-)
Thanks, I've done that and had to change your code a little in order to provide the same behaviour as the Java equivalent. (return -1 when no data can be read). The following is the implementation I use without problems now: --- snip --- (defn concat-input-stream "Gets one or many input streams and returns a new input stream that concatenates the given streams." ^java.io.InputStream [^java.io.InputStream is & more] (proxy [java.io.InputStream] [] (read ([] (let [input (.read is)] (if (and (== -1 input) (seq more)) (.read (apply concat-input-stream (first more) (rest more))) input))) ([arr] (loop [i 0] (if (== i (alength arr)) i (let [input (.read this)] (if (== -1 input) (if (== 0 i) input i) (do (clojure.core/aset arr i (byte input)) (recur (inc i)))))))) ([arr off len] (loop [i 0] (if (or (== i len) (== (+ off i) (alength arr))) i (let [input (.read this)] (if (== -1 input) (if (== 0 i) input i) (do (clojure.core/aset arr (+ off i) (byte input)) (recur (inc i))))))))))) --- snip --- Thanks again for your help. Unfortunately I am still not sure what to use if I face even more horrible SGML in the future, but I think the best solution depends on the exact data ... Be that as it may: I am happy now. :) -- Wolodja <babi...@gmail.com> 4096R/CAF14EFC 081C B7CD FF04 2BA9 94EA 36B2 8B7F 7D30 CAF1 4EFC
signature.asc
Description: Digital signature