1. Engineering
  2. Computer Science
  3. this method is used to write and save data in...

Question: this method is used to write and save data in...

Question details
This method is used to write and save data in Java. I am not quite sure what is going on here. Could someone please comment this code so I can get a better understanding? 

if(input == 'S')
    {

        try
        {
            FileOutputStream f0;
            file = new FileOutputStream("savedGame");
            ObjectOutputStream oOStrm = new ObjectOutputStream(file);
            oOStrm.writeObject(this);
            oOStrm.close();
            System.out.println("Game saved");
        } catch (IOException e)
        {
            e.printStackTrace();
            System.out.println("Save unsuccessful");
        }
    }
    return;
}
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution