I've been trying to get my options menu working for the past few hours now and it's just about finished; my only problem now is that the program, for some ridiculous reason, thinks that a file, that exists, doesn't exist.
Here is where I'm loading the file:
public String loadFile(String filePath)
int lineCounter = 0;
ArrayList<String> lines = new ArrayList<>();
final URL url = new URL(getClass().getProtectionDomain().getCodeSource().getLocation().toString()+filePath);
final BufferedReader bufferedReader = new BufferedReader(new FileReader(url.toString()));
String line = null;
while((line = bufferedReader.readLine()) != null)
return lines.toArray(new String[lines.size()]);
Here is the error message:
java.io.FileNotFoundException: file:\C:\Users\Tyler\Java%20Projects\Text%20Based%20Game\build\classes\Options.txt (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileInputStream.open(Native Method)
I've triple checked to make sure that the file does exist and that it has all of the needed information within, the information is a single integer on line 1 that say which music track to use. I've also tried a few different ways to point the program to the file but they all have the same result.
The way that I'm attempting to get it to work is that, no matter where the .jar file is, there will always be an Options.txt in the same folder that will contain all of the options for the program; this will be read from when the program starts up and then written to if anything is changed in the menu. Everything looks like it should work but the program is just keeps throwing a file not found exception...