[forge-users] Using template files from Jar

forge-users at lists.jboss.org forge-users at lists.jboss.org
Mon Feb 16 13:26:12 EST 2015

Hi Jerome,

Add your resources in the same folder structure as the Java class that will consume it and use getClass().getResource() to retrieve a URL instance out of it:

{quote:class=jive_text_macro jive_macro_quote}
URL url = getClass().getResource("voila.txt");

Resource<?> resource = resourceFactory.create(url);

Tip: Using FileResource directly in your addon is a bad practice, as it relies on the physical file. The best would be to use Resource<?>. This makes your code unaware of the resource location.

Best Regards,

George Gastaldi

Posted by forums
Original post: https://developer.jboss.org/message/918944#918944

More information about the forge-users mailing list