How to ensure that my .jar reads data from an offline file

I have a program that is required to read a csv file before starting it. This data was located in the resource folder in my clojure project.

The program worked fine when we got out of it "resources/data.cv"

, however this results in .jar

not being standalone, but requiring a resource folder.

How can I ensure that resources are also compiled at startup lein uberjar

?

I tried (csv/slurp-csv (io/resource "mma_duffing.csv")

, however the .jar file won't run. Any help is greatly appreciated!

+3


source to share


1 answer


If you put your file in the resource directory, you can read it when both are lane and jar running using something like this code:

(defn read-resource [] (slurp (.getResource (ClassLoader/getSystemClassLoader) "mydatafile")))



Hope this works for you ...

+1


source







All Articles