vendredi 22 juillet 2016

Capturing System/out in Clojure

I'm working with a Java package that outputs text to the console and I need to capture that text in a string, but I'm not sure how to do this. From looking at the Clojure documentation it seemed that all I have to do is wrap the java call in with-out-str but that isn't working for me.

Minimal code example: if I try

(with-out-str 
 (.println (System/out) "foo"))

I'm hoping to get a string with the value "foo", but it's still outputting to the console instead. What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire