[stringtemplate-interest] loading via classpath

Oliver Zeigermann oliver.zeigermann at gmail.com
Sat Feb 5 09:07:53 PST 2011


There now is a complete build file inside

http://jmte.googlecode.com/files/templatesurvey.zip

that copies the templates.

2011/2/5 Oliver Zeigermann <oliver.zeigermann at gmail.com>:
> 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