[stringtemplate-interest] loading via classpath
Terence Parr
parrt at cs.usfca.edu
Sat Feb 5 09:23:58 PST 2011
oh right! dang it. i keep assuming my build path is where my source / .stg are. grrr!!!
Ter
On Feb 5, 2011, at 8:24 AM, Oliver Zeigermann wrote:
> public static STGroup simple = new STGroupFile("st4/simple.stg");
>
> works for me. Check that in your *build* directory there actually is
> that template group file in folder st4 (or whatever you have). Using
> ant to build you have to do this explicitly, while Eclipse does this
> automatically. I will add a build target to the ant file of the
> template survey and upload that.
>
> 2011/2/4 Terence Parr <parrt at antlr.org>:
>> yo, this doesn't see to work:
>>
>> File f = new File(fileName);
>> if ( f.exists() ) {
>> url = f.toURI().toURL();
>> }
>> else { // try in classpath
>> ClassLoader cl = Thread.currentThread().getContextClassLoader();
>> url = cl.getResource(fileName);
>> if ( url==null ) {
>> cl = this.getClass().getClassLoader();
>> url = cl.getResource(fileName);
>> }
>> if ( url==null ) {
>> throw new IllegalArgumentException("No such group file: "+
>> fileName);
>> }
>> }
>> }
>>
>> trying Oliver's code to load a template via
>>
>> static STGroup test = new STGroupFile("org/stringtemplate/v4/benchmark/email.stg"); // tried with and w/o leading '/'
>>
>> won't find the file. ideas?
>>
>> Ter
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>>
More information about the stringtemplate-interest
mailing list