Advertisement
Guest User

Untitled

a guest
Jan 9th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. package utils;
  2.  
  3. import java.io.IOException;
  4. import java.io.OutputStream;
  5. import java.io.PrintStream;
  6. import java.io.StringReader;
  7.  
  8. public class ClojureUtils {
  9.  
  10.     public static String eval(String text) {
  11.         PrintStream ps = System.out;
  12.         final StringBuffer buffer = new StringBuffer();
  13.  
  14.         PrintStream printStream = new PrintStream(new OutputStream() {
  15.  
  16.             @Override
  17.             public void write(int b) throws IOException {
  18.                 buffer.append((char) b);
  19.             }
  20.         });
  21.         System.setOut(printStream);
  22.         clojure.lang.Compiler.load(new StringReader(text));
  23.         System.setOut(ps);
  24.  
  25.         return buffer.toString();
  26.     }
  27.  
  28.     static public String value = "hell2o!";
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement