gpt4 book ai didi

jsch - 如何增加 jsch 缓冲区大小?

转载 作者:行者123 更新时间:2023-12-01 02:37:49 25 4
gpt4 key购买 nike

我正在使用 jsch 进行 sftp 文件传输。当我通过设置缓冲区大小 512(-B 选项)sftp B 512 [sftp 服务器名称] 并调用 put 命令使用 sftp 命令发送文件时,我可以以 8.0MBPS 的速度传输文件。 (常规速度为 3.0MBPS)。

当我在 java 中使用 jsch api 进行相同的文件传输时,我只能获得 2.6MBPS。是否有任何选项可以增加 jsch 中的缓冲区大小或提高 jsch 的速度?

这是我的代码...

Channel channel = null;
ChannelSftp channelSftp = null;
log("preparing the host information for sftp.");
try {
JSch jsch = new JSch();

session = jsch.getSession(username, hostname, port);
session.setPassword(password);
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
System.out.println("Host connected.");
channel = session.openChannel("sftp");
channel.connect();
log("sftp channel opened and connected.");
channelSftp = (ChannelSftp) channel;
channelSftp.cd(SFTPWORKINGDIR);
File f = new File(fileName);
channelSftp.put(new FileInputStream(f), f.getName());
log("File transferred successfully to host.");
} catch (Exception ex) {
System.out.println("Exception found while transfer the response.");
ex.printStackTrace();
} finally{

channelSftp.exit();
log("sftp Channel exited.");
channel.disconnect();
log("Channel disconnected.");
session.disconnect();
log("Host Session disconnected.");
}

最佳答案

查看较新版本的 Jsch (1.50),下载速度更快。

关于jsch - 如何增加 jsch 缓冲区大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17858565/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com