src/java/fr/jayasoft/ivy/repository/ssh/Scp.java
/**
     * Copy a local file to a remote site, uses the specified mode when
     * creating the file on the remote side.
     * 
     * @param localFile Path and name of local file.
     * @param remoteTargetDir Remote target directory where the file has to end up (optional)
     * @param remoteTargetName file name to use on the target system 
     * @param mode a four digit string (e.g., 0644, see "man chmod", "man open")
     * @throws IOException in case of network problems
     * @throws RemoteScpException in case of problems on the target system (connection ok)
     */
Copy a local file to a remote site, uses the specified mode when
creating the file on the remote side.

@param localFile Path and name of local file.
Copy a local file to a remote site uses the specified mode when creating the file on the remote side . @param localFile Path and name of local file .
public void put(String localFile, String remoteTargetDir, String remoteTargetName, String mode) 
    throws IOException,RemoteScpException {
        ChannelExec channel = null;
        if ((localFile == null) || (remoteTargetName == null) || (mode == null))
            throw new IllegalArgumentException("Null argument.");
        if (mode.length() != 4)
            throw new IllegalArgumentException("Invalid mode.");
        for (int i = 0; i < mode.length(); i++)
            if (Character.isDigit(mode.charAt(i)) == false)
                throw new IllegalArgumentException("Invalid mode.");
        String cmd = "scp -t ";
        if(remoteTargetDir != null && remoteTargetDir.length() > 0) {
            cmd = cmd + "-d " + remoteTargetDir;
        }
        try {
            channel = getExecChannel();
            channel.setCommand(cmd);
            sendFile(channel, localFile, remoteTargetName, mode);
            channel.disconnect();
        } catch (JSchException e) {
            if (channel != null)
                channel.disconnect();
            throw (IOException) new IOException("Error during SCP transfer."+e.getMessage())
                    .initCause(e);
        }
    }
public void put ( String localFile , String remoteTargetDir , String remoteTargetName , String mode ) throws IOException , RemoteScpException { ChannelExec channel = null ; if ( ( localFile == null ) || ( remoteTargetName == null ) || ( mode == null ) ) throw new IllegalArgumentException ( "Null argument." ) ; if ( mode . length ( ) != 4 ) throw new IllegalArgumentException ( "Invalid mode." ) ; for ( int i = 0 ; i < mode . length ( ) ; i ++ ) if ( Character . isDigit ( mode . charAt ( i ) ) == false ) throw new IllegalArgumentException ( "Invalid mode." ) ; String cmd = "scp -t " ; if ( remoteTargetDir != null && remoteTargetDir . length ( ) > 0 ) { cmd = cmd + "-d " + remoteTargetDir ; } try { channel = getExecChannel ( ) ; channel . setCommand ( cmd ) ; sendFile ( channel , localFile , remoteTargetName , mode ) ; channel . disconnect ( ) ; } catch ( JSchException e ) { if ( channel != null ) channel . disconnect ( ) ; throw ( IOException ) new IOException ( "Error during SCP transfer." + e . getMessage ( ) ) . initCause ( e ) ; } }
Copy a local file to a remote site, uses the specified mode when
 creating the file on the remote side.
Copy a local file to a remote site uses the specified mode when creating the file on the remote side .