is writing

This commit is contained in:
Chayapak 2023-07-04 20:52:21 +07:00
parent dccc24c5d6
commit 270f0d89ec

View file

@ -14,6 +14,8 @@ public class PersistentDataUtilities {
public static JsonObject jsonObject = new JsonObject();
private static boolean isWriting = false;
static {
init();
}
@ -40,6 +42,10 @@ public class PersistentDataUtilities {
public static synchronized void write () {
try {
if (isWriting) return;
isWriting = true;
writer.close();
// ? how do i clear the file contents without making a completely new FileWriter
@ -48,6 +54,8 @@ public class PersistentDataUtilities {
writer.write(jsonObject.toString());
writer.flush();
isWriting = false;
} catch (IOException | ConcurrentModificationException e) {
e.printStackTrace();
}