ScriptEngine: eval(Reader reader) : ScriptEngine « javax.script « Java by API






ScriptEngine: eval(Reader reader)

  
import java.io.FileReader;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class Main {
  public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByName("js");
    try {
      FileReader reader = new FileReader("yourFile.js");
      engine.eval(reader);
      reader.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

   
    
  








Related examples in the same category

1.ScriptEngine: eval(String script)
2.ScriptEngine: getBindings(int scope)
3.ScriptEngine: get(String key)
4.ScriptEngine: put(String key, Object value)