How would I save the output of the program to txt file? in the example I call cmd and ask you to do something, I wanted to save the result to a text file.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class test {
public static void main(String[] args) throws IOException {
String line;
Process saida;
//executa o processo e armazena a referência em 'Saida'
saida = Runtime.getRuntime().exec("cmd /c ipconfig");
//pega o retorno do processo
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(saida.getInputStream()));
//printa o retorno
while ((line = stdInput.readLine()) != null) {
System.out.println(line);
}
stdInput.close();
}
}