Reputation: 43
I have created a program that is creating and loading a Highscores.txt file. I want this program, when opened from a computer other than mine, to still be able to reach the txt file without having to save it in any specific directory. How could this be done?
Upvotes: 0
Views: 93
Reputation: 1
Upvotes: 0
Reputation: 2468
You can use
getClass().getClassLoader().getResource("Highscores.txt").getPath();
The unique condition for this is that the file have to be in the classpath, otherwise, this will be a NullPointerException
Upvotes: 1