Using JavaFX I am trying to redirect Jsch session.SetOutputStream to a TextArea in a form of a PrintStream. PrintStream works as excepted except for the session output.
TextArea PrintStream setup:
ConsoleClass console = new ConsoleClass(textArea);
PrintStream ps = new PrintStream(console, true);
System.setOut(ps);
public class ConsoleClass extends OutputStream {
private TextArea output;
public ConsoleClass(TextArea ta) {
this.output = ta;
}
@Override
public void write(int i) throws IOException {
output.appendText(String.valueOf((char) i));
}
@Override
public void write(byte[] b) throws IOException {
output.appendText(String.valueOf(b);
}
}
Now I pass this ps (PrintStream) to the Jsch class. and I set the OutputStream as follow:
session.SetOutputStream(ps) //Nothing gets displayed
Note:
The ps still displays anything within the jsch class but not within its session.
To see what goes on in the session I have to
remove System.setOut(ps);
add session.SetOutputStream(System.out)
The same behavior applies to the channel.SetOutputStream
jsch:
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
what am I missing? as you can see I am able to append System.out to the TextArea and I am having only the issue with session or channel .setOutputStream(ps)
.setOutputStream only shows what goes on in the session/channel
when it's directed to System.out