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 TypeMethodDescriptionbooleandelete()Deletes thesaveFileDeserializes thesaveFileand returns the values of the deserialized objectvoiddoSerialize(Object obj)Serializes an object and writes to thesaveFilebooleanChecks 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 newFileto 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:
truethe file got deleted;falseif 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:
trueif the save file contains a legitimate instance of a to do list;falseif not
-
doDeserialize
Deserializes thesaveFileand 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.
-