public void get ( String remoteFiles [ ] , String localTargetDirectory ) throws IOException { Session sess = null ; if ( ( remoteFiles == null ) || ( localTargetDirectory == null ) ) throw new IllegalArgumentException ( "Null argument." ) ; if ( remoteFiles . length == 0 ) return ; // String cmd = "scp -f -r"; String cmd = "scp -f " ; for ( int i = 0 ; i < remoteFiles . length ; i ++ ) { if ( remoteFiles [ i ] == null ) throw new IllegalArgumentException ( "Cannot accept null filename." ) ; cmd += ( " " + remoteFiles [ i ] ) ; } try { sess = conn . openSession ( ) ; sess . execCommand ( cmd ) ; receiveFiles ( sess , remoteFiles , localTargetDirectory ) ; sess . close ( ) ; } catch ( IOException e ) { if ( sess != null ) sess . close ( ) ; throw ( IOException ) new IOException ( "Error during SCP transfer." ) . initCause ( e ) ; } }
Download a set of files from the remote server to a local directory .