IOException:使用with-open关闭流

时间:2015-08-07 00:30:03

标签: file-io clojure

出于某种原因,编译并运行此功能(在CIDER中)将导致以下错误:

1. Unhandled java.io.IOException
   Stream closed
(defn file-lines
  [path]
  (with-open [file-reader (clojure.java.io/reader path)]
    (line-seq file-reader)))
(file-lines "test")

示例文件test

one
two
three

显然,预期结果与("one" "two" "three")一致。

0 个答案:

没有答案