import java.lang.*;
import java.io.*;
class test
{
public static void main(String[] a) throws Exception
{
int i;
String[] str = new String[]{"javac","example.java"};
String[] str1 = new String[]{"java","example"};
Runtime r = Runtime.getRuntime();
Process p = null;
Process p1 = null;
p=r.exec(str);
p1=r.exec(str1);
InputStreamReader reader = new InputStreamReader (p1.getInputStream ());
BufferedReader br = new BufferedReader(reader);
FileWriter fw = new FileWriter("this.txt",true);
char[] c = new char[1];
while ((i=br.read())!=-1)
{
c[0] = (char) i ;
fw.write(c);
c = new char[1];
}
fw.close();
}
}
this a simple program using runtime class. is there any termination of 'process' code need to be employed?
Thanks in advance!!!