January 2014
Intermediate to advanced
232 pages
5h 11m
English
One advantage of using Clojure is that we can rely on the rich ecosystem of existing Java libraries. If some functionality is not available natively, we may wish to call out to a Java library to accomplish a particular task. Calling Java classes is very simple, and follows the standard Clojure syntax fairly closely.
When we wish to use a Clojure library, we employ :use and :require statements. However, when we wish to import a Java class, we have to use the :import statement.
| | (ns myns |
| | (:import java.io.File)) |
We can also group multiple classes from the same package in a single import, as follows:
| | (ns myns |
| | (:import [java.io File FileInputStream FileOutputStream])) |
To create ...
Read now
Unlock full access