public void put ( String localFileRegExp , String remoteFile , boolean recursive , FileTransferProgress progress ) throws SshException , ChannelOpenException { GlobRegExpMatching globMatcher = new GlobRegExpMatching ( ) ; String parentDir ; int fileSeparatorIndex ; parentDir = cwd . getAbsolutePath ( ) ; String relativePath = "" ; if ( ( fileSeparatorIndex = localFileRegExp . lastIndexOf ( System . getProperty ( "file.separator" ) ) ) > - 1 || ( fileSeparatorIndex = localFileRegExp . lastIndexOf ( ' ' ) ) > - 1 ) { relativePath = localFileRegExp . substring ( 0 , fileSeparatorIndex + 1 ) ; File rel = new File ( relativePath ) ; if ( rel . isAbsolute ( ) ) { parentDir = relativePath ; } else { parentDir += System . getProperty ( "file.separator" ) + relativePath ; } } File f = new File ( parentDir ) ; // this is 1.2 so do it the long way // f.listFiles(); String [ ] fileListingStrings = f . list ( ) ; File [ ] fileListing = new File [ fileListingStrings . length ] ; for ( int i = 0 ; i < fileListingStrings . length ; i ++ ) { fileListing [ i ] = new File ( parentDir + File . separator + fileListingStrings [ i ] ) ; } String [ ] matchedFiles = globMatcher . matchFileNamesWithPattern ( fileListing , localFileRegExp . substring ( fileSeparatorIndex + 1 ) ) ; if ( matchedFiles . length == 0 ) { throw new SshException ( localFileRegExp + "No file matches/File does not exist" , SshException . CHANNEL_FAILURE ) ; } /* * if(!relativePath.equals("")) for(int i=0;i<matchedFiles.length;i++) * matchedFiles[i] = relativePath + matchedFiles[i]; */ if ( matchedFiles . length > 1 ) { put ( matchedFiles , remoteFile , recursive , progress ) ; } else { putFile ( matchedFiles [ 0 ] , remoteFile , recursive , progress , false ) ; } }
pattern matches the files in the local directory using local as a glob Regular Expression . For the matching file array put is called to copy the file to the remote directory .