I have textField where i write cmd command and i want to get output results from CMD imported into JtextPane. I am getting that but after i execute some command entire output is imported into the textpane instantly and i want to be written line by line the same way as it being written in CMD console.
thanks for help
String input = textField.getText().toString();
try {
Process p = Runtime.getRuntime().exec("cmd /c" + " " + input);
BufferedReader StdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
String s;
while ((s = StdInput.readLine()) != null) {
try {
Document doc = textPane.getDocument();
doc.insertString(doc.getLength(), s + "\n", null);
} catch (BadLocationException exc) {
exc.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}