Fully mirgate main source to Java NIO (except some files in tools).
This commit is contained in:
@@ -28,9 +28,12 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.script.*;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* @author Matze
|
||||
@@ -45,8 +48,8 @@ public abstract class AbstractScriptManager {
|
||||
|
||||
protected ScriptEngine getInvocableScriptEngine(String path) {
|
||||
path = "scripts/" + path;
|
||||
File scriptFile = new File(path);
|
||||
if (!scriptFile.exists()) {
|
||||
Path scriptFile = Paths.get(path);
|
||||
if (!Files.exists(scriptFile)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -57,8 +60,8 @@ public abstract class AbstractScriptManager {
|
||||
|
||||
enableScriptHostAccess(graalScriptEngine);
|
||||
|
||||
try (FileReader fr = new FileReader(scriptFile, CharsetConstants.CHARSET)) {
|
||||
engine.eval(fr);
|
||||
try (BufferedReader br = Files.newBufferedReader(scriptFile, CharsetConstants.CHARSET)) {
|
||||
engine.eval(br);
|
||||
} catch (final ScriptException | IOException t) {
|
||||
log.warn("Exception during script eval for file: {}", path, t);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user