Unable to create and write files
I'm trying to create a save game system for a program I'm making. I'm trying to do this by having the player save their progress to a file with the extension .ksm by writing the player's current data of the currently active "Mission" object (containing everything needed to continue the game from where it was left off) to said file using an ObjectOutputStream. While the program starts up fine and error-free, the data doesn't seem to write.
I double-checked all the directories, and everything was where it should have been, so then I tried commenting out the code that creates a file, manually making one in the directory, and just writing to that. I ran the program, and the file still came up empty. I can't really think of anything else to do, so here's the relevant code:
Code:
...
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
...
String missiondirectory;
Mission misalpha;
File testfile;
FileOutputStream missionos;
ObjectOutputStream missionwriter;
...
public MainController() throws IOException {
missiondirectory = "c:\\tbsmissions";
testfile = new File(missiondirectory+"outputtest.ksm");
...
misalpha = new Mission(testmap1, players);
...
testfile.createNewFile();
missionos = new FileOutputStream(missiondirectory+"outputtest.ksm");
missionwriter = new ObjectOutputStream(missionos);
missionwriter.writeObject(misalpha);
}
So, any obvious problems?