Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.IOException;
- import javax.script.ScriptEngine;
- import javax.script.ScriptEngineManager;
- import javax.script.ScriptException;
- public class Main {
- public static void main (String [] args)
- {
- String variableWhile="";
- File f = new File("c:/scriptJava.java");
- if (f.exists())
- System.out.println("Archivo disponible.");
- try {
- String archivoJs = "";
- FileReader fr = new FileReader("c:/scriptJava.java");
- BufferedReader br = new BufferedReader(fr);
- while ((variableWhile=br.readLine()) != null)
- {
- archivoJs += variableWhile;
- System.out.println("Leido: " + archivoJs);
- }
- ScriptEngineManager sem = new ScriptEngineManager();
- ScriptEngine script = sem.getEngineByName("script");
- script.eval("System.out.println(\"HOLA\");");
- } catch (IOException | ScriptException e) { e.printStackTrace(); }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement