mirror of
https://github.com/plexusorg/toml4j.git
synced 2025-02-11 03:30:00 +00:00
Read files as UTF-8. Fixes https://github.com/mwanji/toml4j/issues/22
This commit is contained in:
parent
d60736e104
commit
4773638a12
1 changed files with 4 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue