import Java.io.*;
/**
* Demonstrates how to run a program and read it"s output
***/
public class ProcessDemo
{
public static void main(String args[]) throws Exception
{
Process process = Runtime.getRuntime().exec("ls");
InputStream standardOutput = process.getInputStream(),
standardError = process.getErrorStream();
int c;
System.out.println("
[ Standard Output ]");
while ((c = standardOutput.read()) != -1)
System.out.print((char)c);
System.out.println("
[ Standard Error ]");
while ((c = standardError.read()) != -1)
System.out.print((char)c);
standardOutput.close();
standardError.close();
}
}