I've never done that in Clojure, but another developer at the company
I work for made a java utility that allows you to refer to classpath
resources as URLs. It's on sourceforge in a package called "OpenHMS
Common Utilities":
http://openhms.sourceforge.net/common-util/
There's a class called
com.healthmarketscience.common.util.resource.Handler that, when
initialized, registers a "resource" URL handler. I think you should be
able to do something like:
;; Call the static init method on the Handler class to register the
resource: URL handler.
;; You just need to do this once before trying to use a resource URL
(. com.healthmarketscience.common.util.resource.Handler init)
;; Use resource:... URLs just like any other
(.openStream (new URL "resource:the/classpath/resource.txt"))
I use this in java code all the time. I've never tried it in Clojure,
but there's no reason it shouldn't work.
If you decide not to use that, then try something like:
(.findResource (.getContextClassLoader (.currentThread Thread))
"your.resource.txt")