Using Jsch for file transfer from remote to local but file getting deleted on getting input stream

22 Views Asked by At

JSch jsch = new JSch();

jsch.setKnownHosts(sftpKnownHost);

jsch.addIdentity(sftpPrivateKey, sftpPrivateKeyPassphrase);

Session jschSession = jsch.getSession(sftpUser, sftpHost, sftpPort);

java.util.Properties config = new java.util.Properties();

config.put("StrictHostKeyChecking", "no");

jschSession.setConfig(config);

jschSession.connect();

ChannelSftp channelSftp = (ChannelSftp) jschSession.openChannel("sftp");

channelSftp.connect();

channelSftp.cd(fileLocation);

channelSftp.get(scrOnDirectory, desOnLocalSystem);

So on get() I am able to get the file but it gets deleted on server

I also tried just getting file and putting data in inputstream and then using Files copy but the file gets deleted even if I put data I call get() and don't copy the file

On filezilla as well I am able to download but file there is not getting deleted

Kindly help in this

0

There are 0 best solutions below