I am trying to access High_Scores.txt
file stored in folder Resources
.
My project tree looks like this:
I am using the code shown below to access the file. Checked this similar question but the solutions are not working in my case.
File file = new File(getClass().getClassLoader().getResource("/Resources/High_Scores.txt").getFile());
But I keep on getting NULLPointerException
. I do not understand this exception clearly in this context. Can someone point out what I am doing wrong?
Update:
If I alter the code to this:
File file = new File(getClass().getClassLoader().getResource("Resources/High_Scores.txt").getFile());
I get FILENOTFOUNDException
.