write-lines

clojure.contrib.io

  • (write-lines f lines)
Writes lines (a seq) to f, separated by newlines. f is opened with
writer, and automatically closed at the end of the sequence.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/io.clj:296 top

(defn write-lines
  "Writes lines (a seq) to f, separated by newlines.  f is opened with
  writer, and automatically closed at the end of the sequence."
  [f lines]
  (with-open [^BufferedWriter writer (writer f)]
    (loop [lines lines]
      (when-let [line (first lines)]
        (.write writer (str line))
        (.newLine writer)
        (recur (rest lines))))))
Vars in clojure.contrib.io/write-lines: defn loop rest str when-let with-open
Used in 0 other vars

Comments top

No comments for write-lines. Log in to add a comment.