Advertisement
Kimeraweb

RIT

Nov 24th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.File;
  3. import java.io.FileReader;
  4. import java.io.IOException;
  5.  
  6. import javax.script.ScriptEngine;
  7. import javax.script.ScriptEngineManager;
  8. import javax.script.ScriptException;
  9.  
  10.  
  11. public class Main {
  12.    
  13.     public static void main (String [] args)
  14.     {
  15.         String variableWhile="";
  16.        
  17.         File f = new File("c:/scriptJava.java");
  18.         if (f.exists())
  19.             System.out.println("Archivo disponible.");
  20.  
  21.         try {
  22.             String archivoJs = "";
  23.             FileReader fr = new FileReader("c:/scriptJava.java");
  24.             BufferedReader br = new BufferedReader(fr);
  25.             while ((variableWhile=br.readLine()) != null)
  26.             {
  27.                 archivoJs += variableWhile;
  28.                 System.out.println("Leido: " + archivoJs);
  29.             }
  30.            
  31.             ScriptEngineManager sem = new ScriptEngineManager();
  32.             ScriptEngine script = sem.getEngineByName("script");
  33.             script.eval("System.out.println(\"HOLA\");");  
  34.         } catch (IOException | ScriptException e) { e.printStackTrace(); }
  35.        
  36.     }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement