Read input file always with UTF8 encoding

master
Jonas Thiel 2013-05-15 16:25:03 +02:00
rodzic 5706f5d356
commit 70fbc9ccde
2 zmienionych plików z 9 dodań i 6 usunięć

Wyświetl plik

@ -153,4 +153,6 @@ firefox,5
site,5 site,5
china,5 china,5
clients,5 clients,5
widget,5 widget,5
ser-feliç,25
santé,25

Wyświetl plik

@ -1,9 +1,6 @@
import wordcram.Word; import wordcram.Word;
import java.io.BufferedReader; import java.io.*;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@ -16,6 +13,7 @@ import java.util.ArrayList;
* WEIGHT will be parsed as a Float * WEIGHT will be parsed as a Float
*/ */
public class WordsReader { public class WordsReader {
private static final String UTF8 = "UTF-8";
private String file; private String file;
public static final String SEPARATOR = ","; public static final String SEPARATOR = ",";
@ -36,10 +34,13 @@ public class WordsReader {
BufferedReader reader; BufferedReader reader;
try { try {
reader = new BufferedReader(new FileReader(file)); reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), UTF8));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
return new Word[0]; return new Word[0];
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return new Word[0];
} }
String line; String line;