Reading Java properties file in Clojure

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 {:a 10, :b 20})) (defn -main (swap! *args* assoc :a (read) :b (read)))

--

If you have any questions or thoughts, don't hesitate to reach out. You can find me as @viksit on Twitter.