src/java/fr/jayasoft/ivy/repository/ssh/Scp.java
/**
     * Create a remote file and copy the contents of the passed byte array into
     * it. The method use the specified mode when creating the file on the
     * remote side.
     * 
     * @param data the data to be copied into the remote file.
     * @param remoteFileName The name of the file which will be created in the remote target directory.
     * @param remoteTargetDirectory Remote target directory where the file has to end up (optional)
     * @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)
     */
Create a remote file and copy the contents of the passed byte array into
it. The method use the specified mode when creating the file on the
remote side.

@param data the data to be copied into the remote file.
@param remoteFileName The name of the file which will be created in the remote target directory.
@param remoteTargetDirectory Remote target directory where the file has to end up (optional)
@param mode a four digit string
@throws IOException in case of network problems
@throws RemoteScpException in case of problems on the target system (connection ok)
Create a remote file and copy the contents of the passed byte array into it . The method use the specified mode when creating the file on the remote side . @param data the data to be copied into the remote file . @param remoteFileName The name of the file which will be created in the remote target directory . @param remoteTargetDirectory Remote target directory where the file has to end up ( optional ) @param mode a four digit string @throws IOException in case of network problems @throws RemoteScpException in case of problems on the target system ( connection ok )
public void put(byte[] data, String remoteFileName, String remoteTargetDirectory, String mode) 
    throws IOException,RemoteScpException {
        ChannelExec channel = null;
        if ((remoteFileName == 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(remoteTargetDirectory != null && remoteTargetDirectory.length() > 0) {
            cmd = cmd + "-d " + remoteTargetDirectory;
        }
        try {
            channel = getExecChannel();
            channel.setCommand(cmd);
            sendBytes(channel, data, remoteFileName, mode);
        } catch (JSchException e) {
            if (channel != null)
                channel.disconnect();
            throw (IOException) new IOException("Error during SCP transfer."+e.getMessage())
                    .initCause(e);
        }
    }
public void put ( byte [ ] data , String remoteFileName , String remoteTargetDirectory , String mode ) throws IOException , RemoteScpException { ChannelExec channel = null ; if ( ( remoteFileName == 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 ( remoteTargetDirectory != null && remoteTargetDirectory . length ( ) > 0 ) { cmd = cmd + "-d " + remoteTargetDirectory ; } try { channel = getExecChannel ( ) ; channel . setCommand ( cmd ) ; sendBytes ( channel , data , remoteFileName , mode ) ; } catch ( JSchException e ) { if ( channel != null ) channel . disconnect ( ) ; throw ( IOException ) new IOException ( "Error during SCP transfer." + e . getMessage ( ) ) . initCause ( e ) ; } }
Create a remote file and copy the contents of the passed byte array into
 it.
Create a remote file and copy the contents of the passed byte array into it .
//channel.disconnect();