Ver Mensaje Individual
  #4 (permalink)  
Antiguo 14/02/2005, 10:03
txuki
 
Fecha de Ingreso: febrero-2005
Mensajes: 1
Antigüedad: 19 años, 3 meses
Puntos: 0
Buenas tardes,
este codigo lo he cogido de otro foro, y, en principio, parece que recoge los valores de un exe pero no estoy seguro porque todavía no lo he probado porque estoy a la espera de que me pasen un EXE que recoja los parametros y me devuelva otros:
public class RunCommand {

public static void main(String args[]) {

String s = null;

try {

//ejecuta el notepad llamando a un fichero prueba.txt
Process p = Runtime.getRuntime().exec("notepad //prueba.txt");



BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));

BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));

// read the output from the command

System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}

// read any errors from the attempted command

System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}

System.exit(0);
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
}
}

Si haces la prueba antes de que la haga yo te agradecería que me digas si ha funcionado.