read-lines

clojure.contrib.io

  • (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/io.clj:307 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.io/read-lines: defn let read-line
Used in 0 other vars

Comments top

1 comment(s) for read-lines.

If you are running this in an emacs slime repl, you may need to add the following lines to you .emacs file, otherwise you'll get odd errors when reading a unicode file.

(set-language-environment "UTF-8")

(setq slime-net-coding-system 'utf-8-unix)

Log in to add a comment.