io ho trovato questo waitFor() che server per verificare se un processo figlio viene chiuso ma non riesco ad integrarlo alla mia applicazione

questo è un esempio funzionante che ho trovato in rete



import java.io.*;

public class EseguiComando {

public static void EseguiComando (String Comando) throws IOException
{
Process proc = Runtime.getRuntime().exec("start command /c "+Comando+" >output.txt");
char c;
try {
proc.waitFor();
}
catch (InterruptedException e) {
System.out.println("E' stata rilevata una InterruptedException: "+e.getMessage());
}
InputStream f = new FileInputStream ("output.txt");
while ((c=(char)f.read())!=(char)-1)
System.out.print(c);
}

public static void main (String args[]) throws IOException
{
String Comando = new String();
int k;
for (k=0;k<args.length;k++) {
if (k>0) Comando = Comando + " ";
Comando = Comando + args[k];
}
try {
System.out.println("Comando: "+Comando);
EseguiComando(args[0]);
}
catch (IOException e) {
System.err.println ("E' stata rilevata una IOException: "+e.getMessage());
}
}

}



ciao