From 4773638a12a08ac1919e0132fa038a06753abb74 Mon Sep 17 00:00:00 2001 From: "moandji.ezana" Date: Sat, 15 Aug 2015 02:12:44 +0200 Subject: [PATCH] Read files as UTF-8. Fixes https://github.com/mwanji/toml4j/issues/22 --- src/main/java/com/moandjiezana/toml/Toml.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/moandjiezana/toml/Toml.java b/src/main/java/com/moandjiezana/toml/Toml.java index 27e41a5..abd8295 100644 --- a/src/main/java/com/moandjiezana/toml/Toml.java +++ b/src/main/java/com/moandjiezana/toml/Toml.java @@ -2,6 +2,7 @@ package com.moandjiezana.toml; import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; @@ -62,14 +63,14 @@ public class Toml { /** * Populates the current Toml instance with values from file. * - * @param file The File to be read + * @param file The File to be read. Expected to be encoded as UTF-8. * @return this instance * @throws IllegalStateException If file contains invalid TOML */ public Toml read(File file) { try { - return read(new FileReader(file)); - } catch (FileNotFoundException e) { + return read(new InputStreamReader(new FileInputStream(file), "UTF8")); + } catch (Exception e) { throw new RuntimeException(e); } }