Package com.sshtools.j2ssh
Class ScpClient
- java.lang.Object
-
- com.sshtools.j2ssh.ScpClient
-
public final class ScpClient extends java.lang.ObjectImplements a Secure Copy (SCP) client. This may be useful when the server does not support SFTP.
- Since:
- 0.2.0
- Version:
- $Revision: 1.18 $
- Author:
- Lee David Painter
-
-
Constructor Summary
Constructors Constructor Description ScpClient(SshClient ssh, boolean verbose, ChannelEventListener eventListener)Creates an SCP client.ScpClient(java.io.File cwd, SshClient ssh, boolean verbose, ChannelEventListener eventListener)Creates an SCP client.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamget(java.lang.String remoteFile)Gets a remote file as anjava.io.InputStream.voidget(java.lang.String localFile, java.lang.String[] remoteFiles, boolean recursive)Downloads an array of remote files to the local computer.voidget(java.lang.String localFile, java.lang.String remoteFile, boolean recursive)Downloads a remote file onto the local computer.voidput(java.io.InputStream in, long length, java.lang.String localFile, java.lang.String remoteFile)Uploads ajava.io.InputStreamto a remove server as file.voidput(java.lang.String[] localFiles, java.lang.String remoteFile, boolean recursive)Uploads an array of local files onto the remote server.voidput(java.lang.String localFile, java.lang.String remoteFile, boolean recursive)Uploads a local file onto the remote server.
-
-
-
Constructor Detail
-
ScpClient
public ScpClient(SshClient ssh, boolean verbose, ChannelEventListener eventListener)
Creates an SCP client. CWD (Current working directory) will be the CWD of the process that started this JVM.
- Parameters:
ssh- A connected SshClientverbose- Output verbose detaileventListener-- Since:
- 0.2.0
-
ScpClient
public ScpClient(java.io.File cwd, SshClient ssh, boolean verbose, ChannelEventListener eventListener)Creates an SCP client.
- Parameters:
cwd- The current local directoryssh- A connected SshClientverbose- Output verbose detaileventListener-- Since:
- 0.2.0
-
-
Method Detail
-
put
public void put(java.io.InputStream in, long length, java.lang.String localFile, java.lang.String remoteFile) throws java.io.IOExceptionUploads a
java.io.InputStreamto a remove server as file. You must supply the correct number of bytes that will be written.- Parameters:
in- stream providing filelength- number of bytes that will be writtenlocalFile- local file nameremoteFile- remote file name- Throws:
java.io.IOException- on any error
-
get
public java.io.InputStream get(java.lang.String remoteFile) throws java.io.IOExceptionGets a remote file as an
java.io.InputStream.- Parameters:
remoteFile- remote file name- Returns:
- stream
- Throws:
java.io.IOException- on any error
-
put
public void put(java.lang.String localFile, java.lang.String remoteFile, boolean recursive) throws java.io.IOExceptionUploads a local file onto the remote server.
- Parameters:
localFile- The path to the local file relative to the local current directory; may be a file or directoryremoteFile- The path on the remote server, may be a file or directoryrecursive- Copy the contents of a directory recursivly- Throws:
java.io.IOException- if an IO error occurs during the operation- Since:
- 0.2.0
-
put
public void put(java.lang.String[] localFiles, java.lang.String remoteFile, boolean recursive) throws java.io.IOExceptionUploads an array of local files onto the remote server.
- Parameters:
localFiles- an array of local files; may be files or directoriesremoteFile- the path on the remote server, may be a file or directory1recursive- Copy the contents of directorys recursivly- Throws:
java.io.IOException- if an IO error occurs during the operation- Since:
- 0.2.0
-
get
public void get(java.lang.String localFile, java.lang.String[] remoteFiles, boolean recursive) throws java.io.IOExceptionDownloads an array of remote files to the local computer.
- Parameters:
localFile- The local path to place the filesremoteFiles- The path of the remote filesrecursive- recursivly copy the contents of a directory- Throws:
java.io.IOException- if an IO error occurs during the operation- Since:
- 0.2.0
-
get
public void get(java.lang.String localFile, java.lang.String remoteFile, boolean recursive) throws java.io.IOExceptionDownloads a remote file onto the local computer.
- Parameters:
localFile- The path to place the fileremoteFile- The path of the file on the remote serverrecursive- recursivly copy the contents of a directory- Throws:
java.io.IOException- if an IO error occurs during the operation- Since:
- 0.2.0
-
-