When i am trying to move file from fileDirectory1 to fileDirectory2 .. Is there any way to move or copy that file from one path to another in one FTP server.Please anyone can help me.
Here is my sample code:
String existingfile = file.getFilename();
String newfile =file.getFilename();
String fileDirectory1 = clients.getFtpFolder() + "/" + "unprocessed" + "/";
String fileDirectory2 = clients.getFtpFolder() + "/" + "processed" + "/";
sftpChannel.cd(fileDirectory1);
if (sftpChannel.get(newfile) != null){
sftpChannel.rename(fileDirectory1 + newfile ,
fileDirectory2 + newfile );
sftpChannel.cd(fileDirectory2);
sftpChannel.rm(existingfile );
}
Console:
Caused by:2: No such file
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2846)
I have tried How to move file from directory A to directory B in remote server?
Move a directory in remote server to another location in the same remote server using jsch