Skip to content

Commit

Permalink
Fix data not writing to JSON file at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Burchard36 committed Dec 8, 2021
1 parent 0429541 commit f49ea71
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/com/burchard36/json/PluginJsonWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.burchard36.Logger;
import com.google.gson.Gson;
import com.google.gson.stream.JsonWriter;

import java.io.*;
import java.nio.file.Files;
Expand Down Expand Up @@ -37,7 +38,10 @@ public void writeDataToFile(final JsonDataFile config) {
if (!file.exists()) file = this.createFile(config);

try {
this.gson.toJson(config, new FileWriter(file));
final Writer writer = new FileWriter(file);
this.gson.toJson(config, writer);
writer.flush();
writer.close();
} catch (IOException ex) {
ex.printStackTrace();
}
Expand Down

0 comments on commit f49ea71

Please sign in to comment.