• (spit f content)
Opposite of slurp. Opens f with writer, writes content, then
closes f.

1 Example top

  • (defn append-to-file
        "Uses spit to append to an output file.
         ostr is the string, and file-name is an
         actual file name read in using slurp or
         a constant in double quote characters."
         
        [file-name ostr]
        (spit file-name ostr :append true))
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/duck_streams.clj:258 top

(defn spit
  "Opposite of slurp.  Opens f with writer, writes content, then
  closes f."
  [f content]
  (with-open [^PrintWriter w (writer f)]
      (.print w content)))
Vars in clojure.contrib.duck-streams/spit: defn spit with-open
Used in 0 other vars

Comments top

No comments for spit. Log in to add a comment.