On Wed, Jul 11, 2012 at 12:32 +0200, Tassilo Horn wrote: > Wolodja Wentland <babi...@gmail.com> writes: > > > On Tue, Jul 10, 2012 at 17:16 +0200, Tassilo Horn wrote: > >> I think, I'd simply copy the clojure.xml code and adapt it to my needs. > > > >> Not too pretty, but should be adequate for getting the job done. > > > > I look into that, but it really wouldn't be pretty. I still think that > > it must be possible to add two lines (one line each at beginning/end) > > to a file that I am reading. I would know how to do that if I weren't > > working with inputstreams (which the parse functions expect me to use) > > but sequences of lines. > > Hm, I think, you can use proxy to create a concatenation of input > streams. Something like > > --8<---------------cut here---------------start------------->8--- > (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))))) > > (def mystream (concat-input-stream (java.io.ByteArrayInputStream. (.getBytes > "ab")) > (java.io.ByteArrayInputStream. (.getBytes > "cd")) > (java.io.ByteArrayInputStream. (.getBytes > "ef")))) >
Great! I think that I would eventually run into the problems detailed in http://tech.puredanger.com/2011/08/12/subclassing-in-clojure/ but thanks a lot for this inspiration. -- Wolodja <babi...@gmail.com> 4096R/CAF14EFC 081C B7CD FF04 2BA9 94EA 36B2 8B7F 7D30 CAF1 4EFC
signature.asc
Description: Digital signature