Source Code : Show how to use exec to pass complex args
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Show how to use exec to pass complex args
import java.io.*;
/*
* Show how to use exec to pass complex args (which are almost
* certainly system-dependant) to a command-line interpreter.
*/
public class ExecShellArgs {
public static void main(String[] args) throws IOException {
Runtime r = Runtime.getRuntime();
String[] nargs = { "sh", "-c", "for i in 1 2 3; do echo $i; done" };
Process p = r.exec(nargs);
BufferedReader is =
new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = is.readLine()) != null)
System.out.println(line);
}
}
Thank with us