我正在使用 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.");
}