9
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();
}
}
Tôi không muốn sftpChannel.get ("remotefile.txt", "localfile.txt");Sao chép tệp trong sftp bằng thư viện jsch
Tôi chỉ muốn tạo ra hai phương pháp 1) để sao chép các tập tin từ vị trí từ xa vào hệ thống địa phương 2) để loại bỏ các tập tin sao chép trong một kết nối SFTP
bất cứ ai có thể giúp ..
Khi tôi làm một 'c.get (fsrc, fdest) 'tôi thấy các tập tin từ xa bị xóa ... những gì có thể là sai lầm? – Divs