0

I want to perform a remote copy of data from a remote HP-UX server to my local file system using the sshj library.

The data on this remote server has the form: DATA_<YEAR>.dat. For example:

DATA_1998.dat
DATA_1999.dat
DATA_2000.dat
DATA_2001.dat
DATA_2002.dat

The specific method I'm using is the following:

SSHClient.newSCPFileTransfer().download(String remotePath, LocalDestFile localFile)

Given a starting and ending year (i.e. 1991 and 2001), how can I construct a String to pass as the remotePath parameter to copy the range of files between the given start and end years?

Kasa
  • 189
  • 2
  • 13
  • If any further clarification is needed, I'm happy to provide more details. – Kasa Aug 31 '15 at 15:57
  • You should consider using the SFTP protocol instead of SCP. SFTP would let you get a list of files in the remote directory and then retrieve the files that you want to get. – Kenster Sep 01 '15 at 01:46

1 Answers1

0

Generate each filename individually and then copy one by one.

final int START = 1998;
final int END = 2001;
for (int y = START; y <= END; y++) {
    final String year = "DATA_" + y;
    System.out.println(year);
}

Otherwise you could try separating the files by a comma or space to see if that works.

mvd
  • 2,596
  • 2
  • 33
  • 47