I am using JSCH to download files from SFTP server. I am using single session, with multiple channels to download files from different folders located in SFTP. For this downloading process I have a set of scheduled jobs. Each job will:
- open a new channel (
ChannelSftp) everytime. channel name : sftp - uses method
ChannelSftp.ls()to get the size of total number of files to download - If size(Vector) is greater than zero then uses
ChannelSftp.get(remotedir/'*.*', localdir)to download all the files - finally closes the opened channel.
During the above process most of the times I am getting File Not Found or No Such File Exceptions and not downloading some files.
Can anyone please suggest me why it will happen. What may be the cause. How to resolve this problem
below is the code I am using:
ChannelSftp channelSftp = null;
try {
channelSftp = getChannelConnectionUtil().openChannel(); //SFTPConnection.getSession().openChannel("sftp");
@SuppressWarnings("rawtypes")
Vector numOfFiles = channelSftp.ls(ftpDir+"/*.*");
if(numOfFiles.size() > 0){
channelSftp.get(ftpDir+"/*.*",localDir); // Here I am getting error
}
} catch (Exception e) {
e.printStackTrace();
} finally {
getChannelConnectionUtil().disconnectChannel(channelSftp);
}
ChannelSftp.get()allows wildcards? - user207421