Class ImportExportStorage
java.lang.Object
dev.chicoferreira.lifestealer.user.persistent.ImportExportStorage
This class is responsible for importing and exporting user data to and from files.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Constructor Summary
ConstructorsConstructorDescriptionImportExportStorage(Path basePath, UserPersistentStorage userPersistentStorage) -
Method Summary
Modifier and TypeMethodDescriptionintexportToFile(String path) Exports every user to a file.intimportFromFile(String path) Imports every user from a file.Returns a list of all files in the base directory.
-
Constructor Details
-
ImportExportStorage
-
-
Method Details
-
importFromFile
Imports every user from a file. This file must be a JSON file containing an array ofLifestealerUser.The format of the file format should follow the default serialization format of
LifestealerUserin GSON.- Parameters:
path- The path to the file to import from- Returns:
- The number of users imported
- Throws:
Exception- If an error occurs while importing
-
exportToFile
Exports every user to a file.- Parameters:
path- The path to the file to export to- Returns:
- The number of users exported
- Throws:
Exception- If an error occurs while exporting
-
listFiles
Returns a list of all files in the base directory.- Returns:
- A list of all files in the base directory
-