I have to execute a shell commande windows from java swing app and get real time result :
String cmd = jTextField1.getText();
StringBuffer output = new StringBuffer();
Process p;
try {
p = Runtime.getRuntime().exec(cmd);
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = reader.readLine()) != null) {
System.out.println("" + line);
jTextArea1.append(line + "n");
}
} catch (Exception e) {
e.printStackTrace();
}
the problem is that writing in jTextArea is after execute finish not real time like System.out.println(..) .
Aucun commentaire:
Enregistrer un commentaire