Comment lire et Exécuter un fichier de Script

Author:


{filelink=959}


import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Reader;

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

public class ExecuterFichierScript
{
  public static void main(String[] args) throws Exception
  {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine jsEengine = manager.getEngineByExtension("js");
    Reader reader = new InputStreamReader(new FileInputStream("fichier.js"));
    jsEengine.eval(reader);
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *