Interesting - thanks for this. So is it fair to assume that the JVM is ok with 
reading URL resources that are zipped in a jar. I also assume to have an actual 
non-zipped version of the resource I need to copy the file from inside the 
zipped jar to an external path in my file system?

Sam

---
http://sam.aaron.name

On 5 Nov 2011, at 14:03, Ben Smith-Mannschott wrote:

> On Sat, Nov 5, 2011 at 14:42, Sam Aaron <[email protected]> wrote:
>> Hi there,
>> 
>> consider there exists foo.jar on Clojars which contains a bunch of asset 
>> files i.e. png images. If I were to declare foo as one of my project's 
>> dependencies, is it possible to get access to those asset files? I 
>> essentially want a path to a non-zipped version of each asset.
> 
> These kinds of assets are known as "resources" in java parlance. A
> resource is named by a path relative to an entry in the classpath.
> Declaring foo as a dependency will place it in the classpath. The name
> of the resource will therefore be the path of the asset within
> foo.jar.
> 
> Give clojure.java.io/resource [1] that name, and it will return a URL.
> 
> Pass that URL to clojure.java.io/input-stream [2] to open the resource
> for reading.
> 
> [1] 
> http://clojure.github.com/clojure/clojure.java.io-api.html#clojure.java.io/resource
> 
> [2] 
> http://clojure.github.com/clojure/clojure.java.io-api.html#clojure.java.io/input-stream
> 
> hth,
> Ben
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to