Java - Saving file from JAR to disk -


i'm trying save yaml formatted file packaged in jar user's disk.

the file named config.yml , sits directly under 1 of project's source folders. can confirm file packaged in jar winrar.

i using following code file jar:

file file = new file(this.getclassloader().getresource("config.yml").getpath()); 

and using code copy file directory:

fileutils.copyfiletodirectory(file, this.getdatafolder()); 

the getdatafolder() method implemented reliable 3rd party api. however, when use file instance defined same getdatafolder() file instance , path "config.yml":

new file(this.getdatafolder(), "config.yml") 

the console logs filenotfoundexception. file path given in stack trace this: "file:\c:\users\evan\desk top\test%20server\plugins\lottocrates-1.0.jar!\config.yml" seems correct. tried opening file run prompt, able open jar with, not config.yml file.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -