At the moment, in my java program, I am accessing a file that is in the project folder. When I’m loading the file its path is “./src/package/package/file.txt”. When I build the program into an executable it dosen’t work.
I would prefer the files to be outside of the .jar, but in the same folder, how would I got about this?
Samishal
You can use
Class.getResourceAsStreamto get theInputStream. It works for jar package too. It is not possible to access the file in jar file usingFileAPI directly.More details at http://blog.gigadot.net/2010/10/loading-classpath-resources.html