liveBook · Manning

Clojure.java.io/file

As explained in Clojure: The Essential Reference

clojure.java.io/file is a Clojure function that constructs a java.io.File representation from supported path components and locations.

Constructs a java.io.File representation from one or more supported locations or path components. With one argument, it accepts a string, File, URL, URI, or nil; it does not create a physical file. section 22.8

Compose a nested path

(io/file "/root" "logs" "today.txt") ;; #object[java.io.File ... "/root/logs/today.txt"] (apply io/file ["/tmp" "a" "b" "file.txt"]) ;; java.io.File for /tmp/a/b/file.txt section 22.8

How Clojure: The Essential Reference covers it

How deep it goes
Defines accepted inputs, composition rules, nil behavior, and relative-path errors, but does not create physical resources.
Examples
Demonstrates direct construction, nested relative components, nil, URL and URI inputs, and dynamically applied path segments.
What it assumes
Assumes basic Clojure function calls and path strings while teaching supported Java location types and relative-path constraints.
What you can do after
Apply it via clojure.java.io to compose reusable file locations for subsequent I/O operations.
How it connects
Connects java.io.File with URLs, URIs, clojure.java.io/Coercions, readers, writers, and file-copy operations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Clojure: The Essential Reference. The section links point to the parts of the book it draws on.