Class FileManager
java.lang.Object
theLocalLoop.FileManager
FileManager class for handling file input and output operations related to events.
Contains methods for saving events to a file, loading events from a file, adding an event to the file, editing an event in the file, and deleting an event from the file.
Contains methods for saving events to a file, loading events from a file, adding an event to the file, editing an event in the file, and deleting an event from the file.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic LinkedList<Event> Adds an event to the file by first loading the current events from the file, adding the new event to the list, then saving the updated list back to the file.static voiddeleteEvent(Event event) Deletes an event from the file by first loading the current events from the file, removing the specified event from the list, then saving the updated list back to the file.static voidEdits an event in the file by first loading the current events from the file, finding the specified event in the list and updating its details, then saving the updated list back to the file.static LinkedList<Event> Loads events from a file called "events.txt" and returns them as a LinkedList of Event objects.static voidsaveEvents(LinkedList<Event> events) Saves a list of events to a file called "events.txt".
-
Field Details
-
FILE_NAME
-
-
Method Details
-
saveEvents
Saves a list of events to a file called "events.txt". Each event is saved in the following format:
name | date | time | duration | type(s) | format | organizer | password | location- Parameters:
events- LinkedList of Event objects representing the list of events to save to the file.
-
loadEvents
Loads events from a file called "events.txt" and returns them as a LinkedList of Event objects.- Returns:
- LinkedList of Event objects representing the events loaded from the file. If the file does not exist or an error occurs while reading the file, an empty LinkedList is returned.
-
addEvent
Adds an event to the file by first loading the current events from the file, adding the new event to the list, then saving the updated list back to the file.- Parameters:
event- Event object representing the event to add to the file.- Returns:
- LinkedList of Event objects representing the updated list of events after adding the new event.
-
deleteEvent
Deletes an event from the file by first loading the current events from the file, removing the specified event from the list, then saving the updated list back to the file.- Parameters:
event- Event object representing the event to delete from the file.
-
editEvent
Edits an event in the file by first loading the current events from the file, finding the specified event in the list and updating its details, then saving the updated list back to the file.- Parameters:
event- Event object representing the event to edit in the file.input- Scanner object for user input to determine which attribute of the event to edit and the new value for that attribute.
-