How do you load program resources such as icons, strings, graphical elements, scripts, and so on in a Clojure program? I am using a project layout similar to that in many Java p
I placed the file in testpkg/test.txt (relative to current directory).
Code:
(def x 5)
(def nm "testpkg/test.txt")
(def thr (Thread/currentThread))
(def ldr (.getContextClassLoader thr))
(def strem (.getResourceAsStream ldr nm))
(def strem2 (ClassLoader/getSystemResource nm))
(. System/out (println "First Approach:"))
(. System/out (println strem))
(. System/out (println))
(. System/out (println))
(. System/out (println "Second Approach:"))
(. System/out (println strem2))
$ java -cp .\;clojure.jar clojure.main test.clj
First Approach: java.io.BufferedInputStream@1549f94
Second Approach: file:/C:/jsight/javadevtools/clojure-1.1.0/testpkg/test.txt