Skip to content

Commit

Permalink
[fix] charset toJson (#42)
Browse files Browse the repository at this point in the history
* [fix] charset

* [fox] UTF16
  • Loading branch information
joshuajeschek authored Jan 27, 2022
1 parent 899df99 commit 7ce04a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/main/java/github/weichware10/util/config/ConfigWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import github.weichware10.util.Logger;
import github.weichware10.util.db.DataBaseClient;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;


/**
Expand Down Expand Up @@ -41,7 +44,10 @@ public static boolean toJson(String location, Configuration configuration) {
String json = ow.writeValueAsString(configuration);

// Öffnen der Datei
BufferedWriter writer = new BufferedWriter(new FileWriter(location, false));
File file = new File(location);
FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_16);
BufferedWriter writer = new BufferedWriter(osw);

// Schreiben des JSON
writer.append(json);
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/github/weichware10/util/data/TrialData.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
import github.weichware10.util.ToolType;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import javafx.geometry.Rectangle2D;
Expand Down Expand Up @@ -210,7 +212,10 @@ public static boolean toJson(String location, TrialData trialData) {
String json = ow.writeValueAsString(trialData);

// Öffnen der Datei
BufferedWriter writer = new BufferedWriter(new FileWriter(location, false));
File file = new File(location);
FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_16);
BufferedWriter writer = new BufferedWriter(osw);

// Schreiben des JSON
writer.append(json);
Expand Down

0 comments on commit 7ce04a6

Please sign in to comment.