Skip to content

Commit

Permalink
Add UTF-8 CharSet for file writer to avoid issues with incorrect char…
Browse files Browse the repository at this point in the history
… saving.
  • Loading branch information
BONNe committed Sep 8, 2019
1 parent 25f20ce commit 902a199
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand Down Expand Up @@ -297,7 +298,8 @@ public boolean generateDefaultChallengeFile(User user, World world, boolean over
defaultChallenges.setLevelList(levelList);
defaultChallenges.setVersion(this.addon.getDescription().getVersion());

BufferedWriter writer = new BufferedWriter(new FileWriter(defaultFile, false));
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(defaultFile), StandardCharsets.UTF_8));
writer.write(Objects.requireNonNull(
new DefaultJSONHandler(this.addon).toJsonString(defaultChallenges)));
writer.close();
Expand Down

0 comments on commit 902a199

Please sign in to comment.