Java Script eval(String script)

Here you can find the source of eval(String script)

Description

eval

License

Open Source License

Declaration

private static String eval(String script) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    private static String eval(String script) {
        ScriptEngineManager sem = new ScriptEngineManager();
        ScriptEngine se = sem.getEngineByName("javascript");
        String res = "";

        try {//  www.  j a v  a 2  s. c  o  m
            res = String.valueOf(se.eval(script));
        } catch (ScriptException e) {
            e.printStackTrace();
        }

        return res;
    }
}

Related

  1. dbObjectFromMap(Map from)
  2. decodeB64_TO_UTF8(String encodedStr)
  3. escapeJavascript(String str)
  4. eval(String expression, Object... arguments)
  5. eval(String name, Map params)
  6. evaluateExpression(String expr)
  7. evaluateExpression(String s)
  8. executeAppleScript(String script)
  9. executeScript(String script)