Repository : load testé

This commit is contained in:
Maximilien LEDOUX
2022-03-08 12:12:04 +01:00
parent d979fbd1f3
commit 4291618774
4 changed files with 43 additions and 6 deletions

View File

@@ -92,8 +92,8 @@ public class JsonAdapter implements Adapter {
return this.appData;
} catch (JsonParseException parseException) {
System.out.println("[FFE] : Error while loading configuration file"); //TODO - changer en log
return null;
}
return null;
}
private void getUsers(JsonArray jsonUsers, List<User> users) {

View File

@@ -10,8 +10,6 @@ import java.nio.file.StandardOpenOption;
public class Repository {
//static final String CONFIG_FILE_PATH = "../../resources/config.json";
static void save(String filePath, Adapter adapter) {
if (filePath != null) {
String jsonAppData = adapter.toString();
@@ -24,12 +22,12 @@ public class Repository {
}
}
AppData load(String filePath, Adapter adapter) {
static AppData load(String filePath, Adapter adapter) {
String jsonString = readFile(filePath);
return adapter.fromString(jsonString);
}
static private String readFile(String filePath) {
private static String readFile(String filePath) {
StringBuilder builder = new StringBuilder();
try (BufferedReader reader = Files.newBufferedReader(Paths.get(filePath).toAbsolutePath(), StandardCharsets.UTF_8)) {
while (reader.ready()) {