Using `line-seq` with `reader`, when is the file closed?

后端 未结 2 1744
谎友^
谎友^ 2020-12-11 04:59

I\'m reading lines from a text file using (line-seq (reader \"input.txt\")). This collection is then passed around and used by my program.

I\'m concern

2条回答
  •  無奈伤痛
    2020-12-11 05:28

    It seems like the clojure.contrib.duck-streams/read-lines is just what you are looking for. read-lines closes the file when there is no input and returns the sequence just like line-seq. Try to look at source code of read-lines.

提交回复
热议问题