Skip to content

Commit

Permalink
Fixes #1 Loading Categories or Confusables json files might fail if n…
Browse files Browse the repository at this point in the history
…ot using UTF-8
  • Loading branch information
SpaceFox committed Dec 26, 2021
1 parent 13ced2e commit dab97e1
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -39,7 +40,7 @@ boolean loadJson() {

boolean loadJson(String jsonFileName) {
boolean initialized = false;
try (FileInputStream stream = new FileInputStream(new File(jsonFileName))) {
try (FileInputStream stream = new FileInputStream(jsonFileName)) {
initialized = loadJson(stream);
} catch (FileNotFoundException e) {
LOGGER.severe("No " + jsonFileName + " data file found. Please regenerate it from CLI or download it.");
Expand All @@ -51,7 +52,7 @@ boolean loadJson(String jsonFileName) {
}

private boolean loadJson(InputStream stream) {
try (Reader reader = new InputStreamReader(stream)) {
try (Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
setData(new GsonBuilder()
.create()
.fromJson(reader, realDataType));
Expand Down

0 comments on commit dab97e1

Please sign in to comment.