2
Guys how would I save the output from the program to txt file ? in the example I call cmd and ask you to accomplish something, wanted to save the result in 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();
}
}
http://www.avajava.com/tutorials/lessons/how-do-i-write-a-string-to-a-file.html
– user60252
http://stackoverflow.com/questions/1053467/how-do-i-save-a-string-to-a-text-file-using-java
– user60252