reader

added
1.2

ns
clojure.java.io

type
function

(reader x & opts)

Attempts to coerce its argument into an open java.io.Reader.
Default implementations always return a java.io.BufferedReader.

Default implementations are provided for Reader, BufferedReader,
InputStream, File, URI, URL, Socket, byte arrays, character arrays,
and String.

If argument is a String, it tries to resolve it first as a URI, then
as a local file name.  URIs with a 'file' protocol are converted to
local file names.

Should be used inside with-open to ensure the Reader is properly
closed.

                (with-open [rdr (clojure.java.io/reader "/tmp/foo.txt")]
    (reduce conj [] (line-seq rdr)))
            
                (with-open [rdr (clojure.java.io/reader "http://www.google.com")]
   (printf "%s\
" (clojure.string/join "\
" (line-seq rdr))))
;; <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" ...
;;=> nil