ClojureDocs

Nav

Namespaces

as-file

clojure.java.io

Available since 1.2
  • (as-file x)
Coerce argument to a file.
1 Example
; It returns a java.io.File object
> (require '[clojure.java.io :as io] )
> (class (io/as-file "."))
java.io.File

; You can call java methods such as File/exists
> (.exists (io/as-file "dummy.txt"))
false
> (.exists (io/as-file "project.clj"))
true
See Also

Returns a java.io.File, passing each arg to as-file. Multiple-arg versions treat the first argum...

Added by eric
1 Note
    By , created 7.2 years ago

    This is a low-level function for getting a file object from a single string. In contrast, (clojure.java.io/file) is a higher-level API that will let you do things like construct paths to files using strings and other file objects, as in (io/file root-dir "subdir" "filename.ext").