diff --git a/src/main/java/com/laosun/stackone/IgnoreItem.java b/src/main/java/com/laosun/stackone/IgnoreItem.java index a41d720..de64e56 100644 --- a/src/main/java/com/laosun/stackone/IgnoreItem.java +++ b/src/main/java/com/laosun/stackone/IgnoreItem.java @@ -29,10 +29,11 @@ public static ArrayList getIgnoreItems() { try { if (!file.exists() && !file.createNewFile()) { LOGGER.info("Fail to create config file."); - } else { - Files.writeString(file.toPath(), "[]", StandardCharsets.UTF_8); } String jsonString = Files.readString(file.toPath()); + if (jsonString.isEmpty()) { + Files.writeString(file.toPath(), "[]", StandardCharsets.UTF_8); + } JsonArray jsonArray = JsonParser.parseString(jsonString).getAsJsonArray(); for (JsonElement user : jsonArray) { IgnoreItem ignore = gson.fromJson(user, IgnoreItem.class);