If you want the file then just:

ClassLoader.getSystemResource('someFile.gsp').file

On Fri, Apr 29, 2011 at 9:25 PM, Ronen Narkis <[email protected]> wrote:

> Iv had the same "pleasure" in going through all the options of loading a
> file from the classpath, iv found that using:
>
> ClassLoader.getSystemResource('someFile.gsp')
>
> Works
> Ronen
>
>
> On Fri, Apr 29, 2011 at 9:15 PM, phil swenson <[email protected]>wrote:
>
>> I just tried to switch over to referencing template files in my gradle
>> project as resources.  I put my "export.template" file in the
>> resources directory.  So my built jar file now has a path like:
>>
>> .gradle/cache/com.softwareag.bas/bas-plugins-localization/jars/bas-plugins-localization-1.0.0-SNAPSHOT.jar!/export.template
>>
>> I then try to access the resource like so:
>>
>>  URL url = getClass().getClassLoader().getResource("export.template")
>>  def exportTemplateFile = new File(url.getFile())
>>
>> if I call file.exists() on this, I get a file doesn't exist error
>>
>> So I gather you just can't access resources in a jar file as a file.
>> If I could just get the resource as a string, I'd be good.  Any
>> suggestions on being able to pull a resource to a string?
>>
>> thanks
>> phil
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>

Reply via email to