Hey,

I don't have a good example, but the right way to do is with resources
which are basically just files that live on the classpath:

* Put the files in a folder on your classpath. If your using
leiningen, the resources/ directory does this by default.
* Get a URL to the file with clojure.java.io/resource. If your file is
root/resources/my-project/my-resource.txt, you'd use (resource
"my-project/my-resource.txt").
* Read the contents of the file by passing the resource URL to
clojure.java.io/reader or one of its friends.

When you jar up your app the resource files will be included in the
jar and "just work".

Hope this helps.

Dave

On Tue, Jun 28, 2011 at 9:12 PM, stu <stuart.hungerf...@gmail.com> wrote:
> Hi,
>
> I'd like to bundle a collection of (JSON) datafiles with a Clojure
> project source tree so that Clojure functions can reliably find and
> open those datafiles.
>
> What's the idiomatic way of going about this?  In the past with other
> languages I've used tricks like Ruby's ".dirname(__FILE__)/..."
> construct but this kind of approach doesn't seem a good fit for
> Clojure or for the JVM facilities it provides.
>
> Can anyone point to a Clojure project that does this well?
>
> Thanks,
>
> Stu
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to