Here you can find the source of evaluateScriptResource(ScriptEngine engine, String resource)
public static synchronized Object evaluateScriptResource(ScriptEngine engine, String resource) throws IOException, ScriptException
//package com.java2s; //License from project: Apache License import com.google.common.io.CharStreams; import javax.script.ScriptEngine; import javax.script.ScriptException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static synchronized Object evaluateScriptResource(ScriptEngine engine, String resource) throws IOException, ScriptException { String script = getScriptResource(resource); return engine.eval(script); }// w ww . jav a2s. com public static synchronized String getScriptResource(String resource) throws IOException { ClassLoader classloader = Thread.currentThread().getContextClassLoader(); InputStream is = classloader.getResourceAsStream(resource); InputStreamReader reader = new InputStreamReader(is); return CharStreams.toString(reader); } }