Class SaveFile

java.lang.Object
no.ntnu.idatt.filehandler.SaveFile

public class SaveFile extends Object
Save file class:
  • Creates a persistent saveFile.
  • Writes an object to the saveFile.
  • Returns the object from the saveFile.
  • Deletes the saveFile.
  • Field Details

    • DIRECTORY

      public static final String DIRECTORY
      Path for save folder
    • SAVE_DIRECTORY

      public static final String SAVE_DIRECTORY
      Directory path where save files are stored
    • EXTENSION

      public static final String EXTENSION
      File extention for save files
      See Also:
      Constant Field Values
  • Constructor Details

    • SaveFile

      public SaveFile(String fileName)
      Generates a new File to store data to in correct directory and correct name convention
      Parameters:
      fileName - the name of the new save file
    • SaveFile

      public SaveFile(File saveFile)
  • Method Details

    • doSerialize

      public void doSerialize(Object obj) throws IOException
      Serializes an object and writes to the saveFile
      Parameters:
      obj -
      Throws:
      IOException - Any exception thrown by the underlying OutputStream.
    • delete

      public boolean delete()
      Deletes the saveFile
      Returns:
      true the file got deleted; false if not
    • isAToDoList

      public boolean isAToDoList()
      Checks if a file contains an object which can be cast to list, and that the list only contains tasks
      Returns:
      true if the save file contains a legitimate instance of a to do list; false if not
    • doDeserialize

      public Object doDeserialize() throws IOException, ClassNotFoundException
      Deserializes the saveFile and returns the values of the deserialized object
      Returns:
      value of the serialized object, needs to be casted to correct object type
      Throws:
      IOException - Any of the usual Input/Output related exceptions.
      ClassNotFoundException - Class of a serialized object cannot be found.