is writing
This commit is contained in:
parent
dccc24c5d6
commit
270f0d89ec
1 changed files with 8 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue