store/[org.clojure/clojure "1.8.0"] clj::clojure.core/with-out-str

Official Documentation

Add notes
Arities
==================================================
   [& body]

Docstring
==================================================
  Evaluates exprs in a context in which *out* is bound to a fresh
  StringWriter.  Returns the string created by any nested printing
  calls.

Source

(defmacro with-out-str
  "Evaluates exprs in a context in which *out* is bound to a fresh
  StringWriter.  Returns the string created by any nested printing
  calls."
  {:added "1.0"}
  [& body]
  `(let [s# (new java.io.StringWriter)]
     (binding [*out* s#]
       ~@body
       (str s#))))

Example 1

Edit
;; Instead of printing the following will place the output normally
;; sent to standard out to a string.
(with-out-str (println "this should return as a string"))
;; => "this should return as a string\n"

Uses on crossclj