使用jsch库复制sftp中的文件

import com.jcraft.jsch.*; public class App { public static void main(String args[]) { JSch jsch = new JSch(); Session session = null; try { session = jsch.getSession("Username", "Host", PORT NO); session.setConfig("StrictHostKeyChecking", "no"); session.setPassword("Password"); session.connect(); Channel channel = session.openChannel("sftp"); channel.connect(); ChannelSftp sftpChannel = (ChannelSftp) channel; sftpChannel.get("remotefile.txt", "localfile.txt"); sftpChannel.exit(); session.disconnect(); } catch (JSchException e) { e.printStackTrace(); } catch (SftpException e) { e.printStackTrace(); } } 

我不想要这个sftpChannel.get(“remotefile.txt”,“localfile.txt”);

我只想创建两个方法1)将文件从远程位置复制到本地系统2)以删除sftp连接中复制的文件

谁能帮忙..

执行远程文件的副本,然后将其删除

 ChannelSftp.get("remotefile.txt", "localfile.txt"); ChannelSftp.rm("remotefile.txt")