clojure.java.io/writer creates a java.io.BufferedWriter while hiding Java I/O adapter details. It accepts resources, streams, files, URLs, sockets, arrays, and strings, and supports options such as encoding and append. section 22.8
Because I/O objects allocate operating-system resources, bind the writer with with-open so it closes after writing. Use spit for concise output or .write/.append for explicit processing. section 22.8
Write and close a file
(with-open [w (io/writer "/tmp/output.txt")] (spit w "Hello\nClojure!!")) (println (slurp "/tmp/output.txt")) ;; Hello ;; Clojure!! ;; nil
