Thursday, January 30, 2014


run system calls through java

import java.io.*;
public class Hello {

    public static void main(String args[]) {
        try {
            Runtime r = Runtime.getRuntime();
Process p = r.exec("ls -l");
p.waitFor();
BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";

while ((line = b.readLine()) != null) {
  System.out.println(line);
}
   }     catch(Exception e1) {}
       

        System.out.println("finished.");
    }
}

No comments:

Post a Comment