file

added
1.2

ns
clojure.java.io

type
function

(file arg) (file parent child) (file parent child & more)

Returns a java.io.File, passing each arg to as-file.  Multiple-arg
versions treat the first argument as parent and subsequent args as
children relative to the parent.

                user> (clojure.java.io/file "/tmp/foo")
#<File /tmp/foo>

user> (clojure.java.io/file "http://asdf.com")
#<File http:/asdf.com>

user> (clojure.java.io/file "/tmp/foo" "bar")
#<File /tmp/foo/bar>
            
                ; Use clojure.java.io to read in resources from the classpath

(ns rescue.core
  (:require [clojure.java.io :as io] ))

; Populate the file on the command line:  
;   echo "Hello Resources!" > resources/hello.txt
(def data-file (io/resource 
                 "hello.txt" ))
(defn -main []
  (println (slurp data-file)) )
; When do "lein run"
; => Hello Resources!
            
                ; slurp can be used directly on value of io/resource

(ns rescue.core
  (require [clojure.java.io :as io]))

; echo "hello world"  > resources/hello.txt
(def data (io/resource "hello.txt"))

(defn -main []
  (println (slurp data-file))
; when do "lein run"
; => hello world