SetOutputStream适用于System.out但不适用于PrintStream

时间:2016-10-25 12:54:47

标签: java javafx outputstream printstream

使用JavaFX我试图以一种PrintStream的形式将Jsch session.SetOutputStream重定向到TextArea。除会话输出外,PrintStream的工作方式除外。

TextArea PrintStream设置:

The ps still displays anything within the jsch class but not within its session. 

现在我将这个ps(PrintStream)传递给Jsch类。我将OutputStream设置如下:

remove System.setOut(ps);
add session.SetOutputStream(System.out)
The same behavior applies to the channel.SetOutputStream

注意:

jsch jsch = new Jsch();
Session session=jsch.getSession(user, host, 22);
session.setPassword(passed);
session.connect(30000);
session.SetOutputStream(ps); // nothing gets displayed
//but when I set it to System.out it shows everything
session.SetOutputStream(System.out) // console shows the commands
if (session.isConnected()){
System.out.println(session.getHost() + "Session is Established");
//this shows in the TextArea
}
Channel channel=session.openChannel("shell");
System.out.println("Testing testing"); //shows in the TextArea

channel.disconnect();
System.out.println ("channel Status" + channel.getExitStatus); 
//shows in the TextArea

要查看会话中发生了什么,我必须

.setOutputStream only shows what goes on in the session/channel 
when it's directed to System.out

jsch:

{{1}}
我错过了什么? 如你所见,我能够将System.out附加到TextArea,我只遇到会话或频道问题.setOutputStream(ps)

{{1}}

0 个答案:

没有答案