0 Replies - 132 Views - Last Post: 02 May 2013 - 10:41 AM Rate Topic: -----

#1 willkara  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-October 08

Having trouble putting Jsch SCP methods in a loop

Posted 02 May 2013 - 10:41 AM

The ultimate goal of the program is to read a CSV file and download the files from the second column and give them names from the first column.

I have had no problem with the CSV portion of it and no problem with downloading a single file.

The trouble I'm having with is adding the code for downloading the files to the while loop that reads the CSV files.


The code for the CSV portion is very simple

CSVReader reader = new CSVReader(new FileReader("/Users/not getting my username/ORSP_Content.csv"));
            String[] nextLine;

            //My guess is that the SCP download code would go into this loop.
            while ((nextLine = reader.readNext()) != null) {
                String localFile = "/opt/test/";
                // nextLine[] is an array of values from the line
                int pos = nextLine[0].indexOf('/', 1 + nextLine[0].indexOf('/', 1 + nextLine[0].indexOf('/')));
    
                localFile += nextLine[0].substring(nextLine[0].lastIndexOf("/")+1);
    
                System.out.println(lfile);
            }



And the code for the SCP Download portion is available from here

I'm using OPENcsv and JSCH for the libraries.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1