java.lang.Object
no.ntnu.idatt.filehandler.SaveFile
Save file class:
- Creates a persistent
saveFile
. - Writes an object to the
saveFile
. - Returns the object from the
saveFile
. - Deletes the
saveFile
.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
delete()
Deletes thesaveFile
Deserializes thesaveFile
and returns the values of the deserialized objectvoid
doSerialize(Object obj)
Serializes an object and writes to thesaveFile
boolean
Checks if a file contains an object which can be cast to list, and that the list only contains tasks
-
Field Details
-
DIRECTORY
Path for save folder -
SAVE_DIRECTORY
Directory path where save files are stored -
EXTENSION
File extention for save files- See Also:
- Constant Field Values
-
-
Constructor Details
-
SaveFile
Generates a newFile
to store data to in correct directory and correct name convention- Parameters:
fileName
- the name of the new save file
-
SaveFile
-
-
Method Details
-
doSerialize
Serializes an object and writes to thesaveFile
- Parameters:
obj
-- Throws:
IOException
- Any exception thrown by the underlying OutputStream.
-
delete
public boolean delete()Deletes thesaveFile
- 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
Deserializes thesaveFile
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.
-