Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy Resource File to Folder? [closed]

Tags:

java

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?
like image 913
Nate Avatar asked Feb 12 '26 16:02

Nate


1 Answers

You can read a file stored in your jar using:

Class.getResourceAsStream(pathToFile);

See this question for details.

like image 153
kgiannakakis Avatar answered Feb 15 '26 05:02

kgiannakakis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!