1

On a java project using Antlr4 and String Template 4 can I get a STGroupFile from a resource contained in project's jar?

I made it works using the absolute path, like

STGroup gd = new STGroupFile("D:\\templates\\bbx.stg");

But I would like to have the .stg file inside the jar.

What am I missing?

4

1 回答 1

4

您应该能够使用相对路径语法访问类路径中任何 jar 文件中的文件:

STGroup group = new STGroupFile("templates/bbx.stg");
于 2013-09-05T17:05:48.567 回答