1.2.0 permalink Arrow_down_16x16
  • (read-lines f)
Like clojure.core/line-seq but opens f with reader. Automatically
closes the reader AFTER YOU CONSUME THE ENTIRE 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/duck_streams.clj:236 top

(defn read-lines
  "Like clojure.core/line-seq but opens f with reader.  Automatically
  closes the reader AFTER YOU CONSUME THE ENTIRE SEQUENCE."
  [f]
  (let [read-line (fn this [^BufferedReader rdr]
                    (lazy-seq
                     (if-let [line (.readLine rdr)]
                       (cons line (this rdr))
                       (.close rdr))))]
    (read-line (reader f))))
Vars in clojure.contrib.duck-streams/read-lines: defn let read-line
Used in 0 other vars

Comments top

1 comment(s) for read-lines.

Note this is deprecated: http://clojure.github.com/clojure-contrib/#duck-streams

Log in to add a comment.