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
Post a Comment