1
0
Fork 0
mirror of https://gitlab.com/kauron/jstudy synced 2024-12-23 00:43:32 +01:00

Save: set default encoding to utf-8 in all systems

This commit is contained in:
Carlos Galindo 2016-12-08 22:08:02 +01:00
parent 76bff4c84b
commit 76faea3fc7
Signed by: kauron
GPG key ID: 83E68706DEE119A3

View file

@ -4,6 +4,7 @@ import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import java.io.*; import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.InputMismatchException; import java.util.InputMismatchException;
import java.util.List; import java.util.List;
@ -53,7 +54,8 @@ public class TestItem {
public static void saveTo(File file, List<TestItem> data) { public static void saveTo(File file, List<TestItem> data) {
try { try {
OutputStreamWriter writer = new FileWriter(file); OutputStreamWriter writer = new OutputStreamWriter(
new FileOutputStream(file), Charset.forName("UTF-8").newEncoder());
for (TestItem item : data) { for (TestItem item : data) {
writer.write(item.getQuestion() + "::" + item.getAnswer() + "\n"); writer.write(item.getQuestion() + "::" + item.getAnswer() + "\n");
} }