Opposite of slurp. Opens f with writer, writes content, then
closes f.
(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))
(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)))
Comments top
No comments for spit. Log in to add a comment.