salve!
ho creato questa classe per la connessione tramite SSH:
codice:
public class SshConnection {
private Session session;
private ChannelShell channel;
public void getConnection(String user, String host, String password, int port) throws InterruptedException, JSchException {
JSch jsch = new JSch();
UserInfo ui = new MyUserInfo();
session = jsch.getSession(user, host, port);
session.setUserInfo(ui);
session.setPassword(password);
session.connect();
channel = (ChannelShell) session.openChannel("shell");
channel.setInputStream(System.in);
channel.setOutputStream(System.out);
channel.connect(3000);
while (true) {
if (channel.isClosed()) {
System.exit(channel.getExitStatus());
} else {
Thread.sleep(1000);
}
}
}
}
ora l'input e l'ouput dono da e verso la console, ma io vorrei redigere il tutto ad un JTextArea (che si trova su un JFrame nel quale già invoco questa classe).
qualche dritta?