1
我正在執行一些命令在Linux上使用JSCH和輸出該命令並在我的JAVAFX應用程序的活動日誌上打印相同。活動日誌沒有得到持續更新在JavaFX
這是一個問題:打印某行後,活動日誌區卡住了。但是,如果我從窗口切換並返回應用程序繼續在日誌區域打印行。我已經調試了好幾次,但無法解決問題。
下面是代碼
channel.connect();
PrintStream commander = new PrintStream(channel.getOutputStream(), true);
commander.println(command_cd);
commander.println(" exit;");
commander.close();
InputStream outputstream_from_the_channel = channel.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(outputstream_from_the_channel));
String jarOutput;
BufferedWriter bw = new BufferedWriter(new FileWriter(resultLogFile.getAbsolutePath(), true));
while ((jarOutput = reader.readLine()) != null) {
this.logger.info("Status Update = " + jarOutput);
System.out.print("Status Update on screen ="+jarOutput + "\n");
bw.write(jarOutput);
bw.newLine();
outputFromUnix.append(jarOutput).append("\n");
// Display in activity log area in realtime.
if (DeploymentTaskController.actLogTArea != null) {
System.out.println("outputFromUnix.toString()---->>>>> " + outputFromUnix.toString());
//actlogArea is TextArea
DeploymentTaskController.actLogTArea.setText(outputFromUnix.toString());
DeploymentTaskController.actLogTArea.end();
}
}
bw.close();
reader.close();
非常感謝謝爾蓋! – Rohan