posted 13 years ago
Hello. I've been learning I/O recently and everything seems fine except for when i put my program into a jar file.
My current program is a game that tests how fast you can type the alphabet and i want it to store the fastest time, which is a double variable in a file. I wanted to use serialisation instead of just using a text file.
Basically my program, when it loads, it tries to read a file that has the highest score in it, if the file isn't there my program catches an exception and then calls a method to write the file. It then saves the fastest time whenever someone beats the old time. This worked absolutely fine! Just how i hoped it would work unitl i put my program into a jar file. Now my program creates the file once opened like it is supposed to but it won't save anything.
I earlier had another program that saved to txt. Even as a jar file this worked fine as long as the files were in the same folder as the application so i had wrongly assumed it would work the same way.
Underneath i will put the code for the methods that read and write from the file. And underneath that i will put the whole class just in case anyone is interested in seeing it. Please can anyone give me some advice on how to handle this and what i need to look into.
And here is the whole class.