Java Mailing List Archive

http://www.gg3721.com/

Home » user.groovy »

[groovy-user] the grooviest way to load a classpath resource

Kallin Nagelberg

2008-08-13

Replies: Find Java Web Hosting

Author LoginPost Reply
A friend of mine is coming to groovy and wanted to know if there's a magical way to load a classpath resource (xml file in this case).
I suggested something like,

def stream = getClass().getResourceAsStream("/Template.xml")
def template = stream.text

Apparently that is not enough magic though.
Is there a way to write something like:

def context = new Resource("/template.xml").text ? I can't imagine how much more magical it could be.
©2008 gg3721.com - Jax Systems, LLC, U.S.A.