Fetch file from specific directory where jar file is placed
问题 I want to fetch a text file from the directory where my jar file is placed. Assuming my desktop application 'foo.jar' file is placed in d:\ in an installation of Windows. There is also a test.txt file in the same directory which I want to read when 'foo.jar' application is running. How can fetch that particular path in my 'foo.jar' application? In short I want to fetch the path of my 'foo.jar' file where it is placed. 回答1: Note, that actual code does depend on actual class location within