Original Post
hi, i can run the following code form cmd: train_sarray.exe -a 13 t.sarray as i ahve created an exe of c files, but i need to run it in java, i am new to processes but i thought that all of the above were arguments, i now find that they are not. t.sarray apparently redirects T2.string to the process and the output to t.sarray, does anyone know how to run this in java? thanks ps i already have the following:
[source=]
public static void train_sarray(String[] cmdline) throws IOException, InterruptedException
{
String arg = "C:\\Documents and Settings\\Danny\\Desktop\\sarray_exe\\train_sarray.exe -a 13 <T2.string>foo.sarry";
/*Process p=Runtime.getRuntime().exec(arg);
p.waitFor();
System.out.println(p.exitValue());*/
//String arg = "./train_sarray -a 4 <T1.string>foo.sarry";
Process p=Runtime.getRuntime().exec(arg);
BufferedInputStream eo = new BufferedInputStream(p.getErrorStream());
BufferedInputStream o = new BufferedInputStream(p.getInputStream());
p.waitFor();
print(eo);
print(o);
System.out.println(p.exitValue());
}
private static void print(BufferedInputStream out)throws IOException{
System.out.println("");
int r = out.read();
while (r!=-1){
System.out.print((char)r);
r=out.read();
}
System.out.println("");
}