(slurp f & opts)
Opens a reader on f and reads all its contents, returning a string. See clojure.java.io/reader for a complete list of supported arguments.
user=> (spit "blubber.txt" "test")
nil
user=> (slurp "blubber.txt")
"test"
;; To access web page. Note the use of http://
;; prefix
user=> (slurp "http://clojuredocs.org")
; This will return the html content of clojuredocs.org
;; Access absolute location on Windows
user=> (slurp "C:\\\\tasklists.xml")
;; On Linux, some JVMs have a bug where they cannot read a file in the /proc
;; filesystem as a buffered stream or reader. A workaround to this JVM issue
;; is to open such a file as unbuffered:
(slurp (java.io.FileReader. "/proc/cpuinfo"))
;; You can specify what encoding to use by giving a :encoding param, and an encoding string recognized by your JVM
user=> (slurp "/path/to/file" :encoding "ISO-8859-1")
;; you can fetch URLs
(slurp "http://www.example.com")
;; you can read bytes also
(def arr-bytes (into-array Byte/TYPE (range 128)))
(slurp arr-bytes)