You're viewing version 1.2.0 of file. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16
  • (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.

2 Examples top

  • 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/file
                     (io/resource 
                       "hello.txt" )))
    (defn -main []
      (println (slurp data-file)) )
    ; When do "lein run"
    ; => Hello Resources!
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/java/io.clj:395 top

(defn ^File file
  "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."
  {:added "1.2"}
  ([arg]                      
     (as-file arg))
  ([parent child]             
     (File. ^File (as-file parent) ^String (as-relative-path child)))
  ([parent child & more]
     (reduce file (file parent child) more)))
Vars in clojure.java.io/file: defn reduce
Used in 0 other vars

Comments top

No comments for file. Log in to add a comment.