javajsche4xmirth

Local directories-files list using jcraft.jsch


I need to transfer list of files from different directories to the destination. I am using JSch library for this purpose.

I can get the list of files or directory list with below mentioned code for the Remote machine.

var jsch = new JSch();
jsch.setConfig('StrictHostKeyChecking','no');
var session = jsch.getSession('username','hostaddress',portnumber);
session.setPassword('password');
session.connect();
var channel = session.openChannel('sftp');
channel.connect();
channel.cd("/direcotry/");
var directoryList = channel.ls("*.txt");

But is there any command/code to get the list of directories and files from the local machine (Linux OS) using jcraft? Because number of directories and files differ during each transfer from the source.

FYI. I need to implement this solution in mirth connect.


Solution

  • You use JSch to access remote files, not local files.


    For local files, use functions for listing local files available in your language/SDK.

    For Java see, Read all files in a folder.