所以,这是我拥有的代码:
try
{
PlayerSave save = new PlayerSave(this);
save.playerLooks = look;
File test = new File("C:/cache/" + playerName + ".tmp");
test.createNewFile();
FileOutputStream f_out = new
FileOutputStream("C:/cache/" + playerName + ".tmp");
ObjectOutputStream obj_out = new ObjectOutputStream (f_out);
obj_out.writeObject (save);
obj_out.close();
f_out.close();
}
catch (Exception e)
{
e.printStackTrace();
}
执行后,我收到以下错误:
java.io.FileNotFoundException: C:\cache\Bobdole.tmp (The system cannot find the path specified)
我也尝试过使用这段代码:
try
{
PlayerSave save = new PlayerSave(this);
save.playerLooks = look;
// File test = new File("C:/cache/" + playerName + ".tmp");
// test.createNewFile();
FileOutputStream f_out = new
FileOutputStream("C:/cache/" + playerName + ".tmp");
ObjectOutputStream obj_out = new ObjectOutputStream (f_out);
obj_out.writeObject (save);
obj_out.close();
f_out.close();
}
catch (Exception e)
{
e.printStackTrace();
}
但是,它会产生相同的错误。我很困惑为什么这不起作用,因为一切似乎都是正确的。如果你们能找出问题,那将非常有帮助。谢谢!!