Repository : load testé
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user