jsch 【stream的理解】

环境

操作系统: win7

getInputStream

public InputStream getInputStream()

官网的解释:

Gets an InputStream for this channel.
All data arriving in SSH_MSG_CHANNEL_DATA messages from the remote side can be read from this stream. 
This method is a polling alternative to setOutputStream(java.io.OutputStream). 
It should be called before connect().

意思:

得到该通道的输入流。
从远程端到达的所有数据消息(格式为:SSH_MSG_CHANNEL_DATA)都能从该流中读取。该方法和`setOutputStream`方法二者选一。
它应该在`connect()`方法之前调用。

getOutputStream

public OutputStream getOutputStream()
Gets an OutputStream for this channel.
All data written to this stream will be sent in SSH_MSG_CHANNEL_DATA messages to the remote side. 
This method is an alternative to setInputStream(java.io.InputStream). 
It should be called before connect().

意思:

得到该通道的输出流。
写入该流中的所有数据,都将发送到远程端,发送的数据格式为`SSH_MSG_CHANNEL_DATA`。
这个方法和`setInputStream`是二者选一的。它应该在`connect()`方法之前调用。

setInputStream

public void setInputStream(InputStream in)

官网:

Sets the InputStream for this channel. 
The channel will then read from this stream and forward the data to the remote side. 
The stream will be closed on disconnect(com.jcraft.jsch.Session). 
This method should be called before connect().

意思:

给该通道设置输入流。
该通道将从该流中读取并转发数据到远程端。
该流将在调用`disconnect`方法后关闭。
该方法应该在`connect`方法之前调用。

setInputStream

public void setInputStream(InputStream in,
                           boolean dontclose)

官网:

Sets the InputStream for this channel. 
The channel will then read from this stream and forward the data in SSH_MSG_CHANNEL_DATA to the remote side. 
This method should be called before connect().

dontclose - if true, we do not close the stream after usage.

意思:

给这个通道设置输入流。
该通道将从这个流中读取数据并转发到远程,数据格式为`SSH_MSG_CHANNEL_DATA`。
这个方法应该在`connect()`方法之前调用。

dontclose 如果为true,再使用完之后,我们不会关闭该流。

setOutputStream

public void setOutputStream(OutputStream out)

官网:

Sets the OutputStream for this channel.
All data arriving in SSH_MSG_CHANNEL_DATA messages from the remote side will be written to this OutputStream. 
This method should be called before connect(). 
The stream will be closed on disconnect(com.jcraft.jsch.Session).

意思:

给这个管道设置输出流。从远程端到达的所有数据消息(格式:SSH_MSG_CHANNEL_DATA)都将被写入到该流中。
这个方法应该在`connect()`方法之前调用。
这个流将在调用`disconnect`后关闭。

setOutputStream

public void setOutputStream(OutputStream out, boolean dontclose)

官网:

Sets the OutputStream for this channel. 
All data arriving in SSH_MSG_CHANNEL_DATA messages from the remote side will be written to this OutputStream. 
This method should be called before connect().

dontclose - if true, we do not close the stream on disconnect(com.jcraft.jsch.Session).

意思:

给这个通道设置输出流。
从远程端到达的所有数据消息(格式:SSH_MSG_CHANNEL_DATA)都将写入到该流中。
这个方法应该在`connect()`之前调用。

dontclose - 如果为真,在执行`disconnect`之后,我们不会关闭该流

参考地址:
http://epaul.github.io/jsch-documentation/javadoc/com/jcraft/jsch/Channel.html#setInputStream-java.io.InputStream-

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

山鬼谣me

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值