title: Using JSch ChannelSftp: How to read multiple files with dynamic names?
body: <p>I have to read a bunch of .CSV files with dynamic file names from a SFTP server. These files get generated every 15 minutes.</p>
  
  <p>I am using JSch's ChannelSftp, but there is no method which would give the exact filenames. I only see an <code>.ls()</code> method. This gives a Vector e.g.</p>
  
  <pre><code>[drwxr-xr-x    2 2019     2019          144 Aug  9 22:29 .,
   drwx------    6 2019     2019          176 Aug 27  2009 ..,
   -rw-r--r--    1 2019     2019          121 Aug  9 21:03 data_task1_2011_TEST.csv,
   -rw-r--r--    1 2019     2019          121 Aug  9 20:57 data_task1_20110809210007.csv]
  </code></pre>
  
  <p>Is there a simple way to read all the files in a directory and copy them to another location?</p>
  
  <p>This code works for copying a single file:</p>
  
  <pre><code>JSch jsch = new JSch();
  session = jsch.getSession(SFTPUSER,SFTPHOST,SFTPPORT);
  session.setPassword(SFTPPASS);
  java.util.Properties config = new java.util.Properties();
  config.put("StrictHostKeyChecking", "no");
  session.setConfig(config);
  session.connect();
  channel = session.openChannel("sftp");
  channel.connect();
  channelSftp = (ChannelSftp)channel;
  channelSftp.cd(SFTPWORKINGDIR);
  channelSftp.get("data_task1_20110809210007.csv","data_task1_20110809210007.csv");
  </code></pre>