ClojureDocs

Nav

Namespaces

PrintWriter-on

clojure.core

Available since 1.10 (source)
  • (PrintWriter-on flush-fn close-fn)
implements java.io.PrintWriter given flush-fn, which will be called
when .flush() is called, with a string built up since the last call to .flush().
if not nil, close-fn will be called with no arguments when .close is called
1 Example
(with-open [writer (PrintWriter-on
                     (fn [s] (printf "Flushing: '%s'%n" s))
                     (fn [] (printf "Closing.%n")))]
   (.write writer "Hello")
   (.flush writer)
   (.write writer "World!")
   (println "About to finish..."))
;; Flushing: 'Hello'
;; About to finish...
;; Flushing: 'World!'
;; Closing.
;; nil
See Also
No see-alsos for clojure.core/PrintWriter-on
0 Notes
No notes for PrintWriter-on