Quantcast
Channel: Viksit Gaur - clojure
Viewing all articles
Browse latest Browse all 10

Reading Java properties file in Clojure

$
0
0

A simple and effective way to read properties files in Clojure, since they transform into Clojure maps!

(into{}(doto(java.util.Properties.)
         (.load(->(Thread/currentThread)
         (.getContextClassLoader)
         (.getResourceAsStream "log4j.properties")))))

Next, to actually read this in, using atoms to swap the values like this seems to work,

(def*args*
  (atom {:a10, :b20}))

(defn-main []
  (swap!*args*assoc :a(read) :b(read)))

Viewing all articles
Browse latest Browse all 10

Trending Articles