Copy Resource File to Folder?

java

Solution

You can read a file stored in your jar using:

Class.getResourceAsStream(pathToFile);

See this question for details.

Problem

I have a need to generate complicated text files from a Java desktop application. I've decided the code would be considerably easier to implement if I could copy a template file and tailor it to whatever needs to be constructed. I will only be distributing a jar to the customers. Is there a best-practice on how to handle this? - Is it even possible to copy a resource from the jar at runtime? - Is it better to "auto-generate" a template on first execution of the jar?

Original source

Related problems