4

Is there something equivalent to Python's StingIO for Clojure?

I'm trying to write a report generating/literate programming system similar to Sweave and Pweave for Clojure. I'm currently using a temp file, but I'd prefer using something similar to StringIO.

Matti Pastell
  • 9,135
  • 3
  • 37
  • 44

2 Answers2

5

with-out-str is pretty handy.

(let [foo (with-out-str (println "Hello world!"))] 
   foo)

More documentation here

dnolen
  • 18,496
  • 4
  • 62
  • 71
2

java.io.StringWriter: http://download.oracle.com/javase/6/docs/api/java/io/StringWriter.html

Stuart Sierra
  • 10,837
  • 2
  • 29
  • 35