Package com.trilead.ssh2
Class SCPClient
- java.lang.Object
-
- com.trilead.ssh2.SCPClient
-
public class SCPClient extends java.lang.ObjectA very basicSCPClientthat can be used to copy files from/to the SSH-2 server. On the server side, the "scp" program must be in the PATH.This scp client is thread safe - you can download (and upload) different sets of files concurrently without any troubles. The
SCPClientis actually mapping every request to a distinctSession.
-
-
Constructor Summary
Constructors Constructor Description SCPClient(Connection conn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidget(java.lang.String[] remoteFiles, java.lang.String localTargetDirectory)Download a set of files from the remote server to a local directory.voidget(java.lang.String remoteFile, java.io.OutputStream target)Download a file from the remote server and pipe its contents into anOutputStream.voidget(java.lang.String remoteFile, java.lang.String localTargetDirectory)Download a file from the remote server to a local directory.voidput(byte[] data, java.lang.String remoteFileName, java.lang.String remoteTargetDirectory)Create a remote file and copy the contents of the passed byte array into it.voidput(byte[] data, java.lang.String remoteFileName, java.lang.String remoteTargetDirectory, java.lang.String mode)Create a remote file and copy the contents of the passed byte array into it.voidput(java.lang.String[] localFiles, java.lang.String remoteTargetDirectory)Copy a set of local files to a remote directory, uses mode 0600 when creating files on the remote side.voidput(java.lang.String[] localFiles, java.lang.String[] remoteFiles, java.lang.String remoteTargetDirectory, java.lang.String mode)voidput(java.lang.String[] localFiles, java.lang.String remoteTargetDirectory, java.lang.String mode)Copy a set of local files to a remote directory, uses the specified mode when creating the files on the remote side.voidput(java.lang.String localFile, java.lang.String remoteTargetDirectory)Copy a local file to a remote directory, uses mode 0600 when creating the file on the remote side.voidput(java.lang.String localFile, java.lang.String remoteTargetDirectory, java.lang.String mode)Copy a local file to a remote directory, uses the specified mode when creating the file on the remote side.voidput(java.lang.String localFile, java.lang.String remoteFileName, java.lang.String remoteTargetDirectory, java.lang.String mode)Copy a local file to a remote directory, uses the specified mode and remote filename when creating the file on the remote side.
-
-
-
Constructor Detail
-
SCPClient
public SCPClient(Connection conn)
-
-
Method Detail
-
put
public void put(java.lang.String localFile, java.lang.String remoteTargetDirectory) throws java.io.IOExceptionCopy a local file to a remote directory, uses mode 0600 when creating the file on the remote side.- Parameters:
localFile- Path and name of local file.remoteTargetDirectory- Remote target directory. Use an empty string to specify the default directory.- Throws:
java.io.IOException
-
put
public void put(java.lang.String[] localFiles, java.lang.String remoteTargetDirectory) throws java.io.IOExceptionCopy a set of local files to a remote directory, uses mode 0600 when creating files on the remote side.- Parameters:
localFiles- Paths and names of local file names.remoteTargetDirectory- Remote target directory. Use an empty string to specify the default directory.- Throws:
java.io.IOException
-
put
public void put(java.lang.String localFile, java.lang.String remoteTargetDirectory, java.lang.String mode) throws java.io.IOExceptionCopy a local file to a remote directory, uses the specified mode when creating the file on the remote side.- Parameters:
localFile- Path and name of local file.remoteTargetDirectory- Remote target directory. Use an empty string to specify the default directory.mode- a four digit string (e.g., 0644, see "man chmod", "man open")- Throws:
java.io.IOException
-
put
public void put(java.lang.String localFile, java.lang.String remoteFileName, java.lang.String remoteTargetDirectory, java.lang.String mode) throws java.io.IOExceptionCopy a local file to a remote directory, uses the specified mode and remote filename when creating the file on the remote side.- Parameters:
localFile- Path and name of local file.remoteFileName- The name of the file which will be created in the remote target directory.remoteTargetDirectory- Remote target directory. Use an empty string to specify the default directory.mode- a four digit string (e.g., 0644, see "man chmod", "man open")- Throws:
java.io.IOException
-
put
public void put(byte[] data, java.lang.String remoteFileName, java.lang.String remoteTargetDirectory) throws java.io.IOExceptionCreate a remote file and copy the contents of the passed byte array into it. Uses mode 0600 for creating the remote file.- Parameters:
data- the data to be copied into the remote file.remoteFileName- The name of the file which will be created in the remote target directory.remoteTargetDirectory- Remote target directory. Use an empty string to specify the default directory.- Throws:
java.io.IOException
-
put
public void put(byte[] data, java.lang.String remoteFileName, java.lang.String remoteTargetDirectory, java.lang.String mode) throws java.io.IOExceptionCreate 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.- Parameters:
data- the data to be copied into the remote file.remoteFileName- The name of the file which will be created in the remote target directory.remoteTargetDirectory- Remote target directory. Use an empty string to specify the default directory.mode- a four digit string (e.g., 0644, see "man chmod", "man open")- Throws:
java.io.IOException
-
put
public void put(java.lang.String[] localFiles, java.lang.String remoteTargetDirectory, java.lang.String mode) throws java.io.IOExceptionCopy a set of local files to a remote directory, uses the specified mode when creating the files on the remote side.- Parameters:
localFiles- Paths and names of the local files.remoteTargetDirectory- Remote target directory. Use an empty string to specify the default directory.mode- a four digit string (e.g., 0644, see "man chmod", "man open")- Throws:
java.io.IOException
-
put
public void put(java.lang.String[] localFiles, java.lang.String[] remoteFiles, java.lang.String remoteTargetDirectory, java.lang.String mode) throws java.io.IOException- Throws:
java.io.IOException
-
get
public void get(java.lang.String remoteFile, java.lang.String localTargetDirectory) throws java.io.IOExceptionDownload a file from the remote server to a local directory.- Parameters:
remoteFile- Path and name of the remote file.localTargetDirectory- Local directory to put the downloaded file.- Throws:
java.io.IOException
-
get
public void get(java.lang.String remoteFile, java.io.OutputStream target) throws java.io.IOExceptionDownload a file from the remote server and pipe its contents into anOutputStream. Please note that, to enable flexible usage of this method, theOutputStreamwill not be closed nor flushed.- Parameters:
remoteFile- Path and name of the remote file.target- OutputStream where the contents of the file will be sent to.- Throws:
java.io.IOException
-
get
public void get(java.lang.String[] remoteFiles, java.lang.String localTargetDirectory) throws java.io.IOExceptionDownload a set of files from the remote server to a local directory.- Parameters:
remoteFiles- Paths and names of the remote files.localTargetDirectory- Local directory to put the downloaded files.- Throws:
java.io.IOException
-
-