Cleanup Read File
This commit is contained in:
parent
1c7f7e4b1a
commit
33f21ed65f
@ -4,9 +4,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -52,10 +52,8 @@ public class Main {
|
|||||||
|
|
||||||
public static void loadDialogFromResources(String fileName) {
|
public static void loadDialogFromResources(String fileName) {
|
||||||
try {
|
try {
|
||||||
InputStream dialogJson = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
story = mapper.readValue(dialogJson, new TypeReference<>() {
|
story = mapper.readValue(Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName), new TypeReference<>() {});
|
||||||
});
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.severe("Error reading the internal dialog File. Exiting now!");
|
logger.severe("Error reading the internal dialog File. Exiting now!");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
@ -64,10 +62,8 @@ public class Main {
|
|||||||
|
|
||||||
public static void loadDialog(String fileName) {
|
public static void loadDialog(String fileName) {
|
||||||
try {
|
try {
|
||||||
InputStream dialogJson = new FileInputStream(fileName);
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
story = mapper.readValue(dialogJson, new TypeReference<>() {
|
story = mapper.readValue(new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8), new TypeReference<>() {});
|
||||||
});
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.severe("Error reading the internal dialog File. Exiting now!");
|
logger.severe("Error reading the internal dialog File. Exiting now!");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user