public class ScpClient extends ScpClientIO
Modifier and Type | Class and Description |
---|---|
protected class |
ScpClient.ScpEngine
Implements an SCP Engine by extending J2SSH Mavericjs ScpEngineIO
|
ScpClientIO.ScpEngineIO
ssh
Constructor and Description |
---|
ScpClient(com.sshtools.common.files.AbstractFileFactory<?> fileFactory,
SshClient ssh)
Creates an SCP client.
|
ScpClient(SshClient ssh)
Creates an SCP client.
|
Modifier and Type | Method and Description |
---|---|
void |
exit() |
void |
get(java.lang.String localDir,
java.lang.String[] remoteFiles,
boolean recursive)
Downloads an array of remote files to the local computer.
|
void |
get(java.lang.String localFile,
java.lang.String[] remoteFiles,
boolean recursive,
FileTransferProgress progress) |
void |
get(java.lang.String localFile,
java.lang.String remoteFile,
boolean recursive)
Downloads a remote file onto the local computer.
|
void |
get(java.lang.String localFile,
java.lang.String remoteFile,
boolean recursive,
FileTransferProgress progress) |
void |
put(java.lang.String[] localFiles,
java.lang.String remoteFile,
boolean recursive)
Uploads an array of local files onto the remote server.
|
void |
put(java.lang.String[] localFiles,
java.lang.String remoteFile,
boolean recursive,
FileTransferProgress progress)
Uploads an array of local files onto the remote server.
|
void |
put(java.lang.String localFile,
java.lang.String remoteFile,
boolean recursive)
Uploads a local file onto the remote server.
|
void |
put(java.lang.String localFileRegExp,
java.lang.String remoteFile,
boolean recursive,
FileTransferProgress progress)
pattern
matches the files in the local directory using "local" as a glob Regular
Expression.
|
void |
putFile(java.lang.String localFile,
java.lang.String remoteFile,
boolean recursive,
FileTransferProgress progress,
boolean remoteIsDir) |
void |
setPacketSize(int packetSize) |
void |
setWindowSpace(int windowSpace) |
public ScpClient(SshClient ssh) throws com.sshtools.common.permissions.PermissionDeniedException, java.io.IOException
Creates an SCP client. CWD (Current working directory) will be the users home directory.
ssh
- A connected SshClientjava.io.IOException
com.sshtools.common.permissions.PermissionDeniedException
public ScpClient(com.sshtools.common.files.AbstractFileFactory<?> fileFactory, SshClient ssh) throws com.sshtools.common.permissions.PermissionDeniedException, java.io.IOException
Creates an SCP client.
cwd
- The current local directoryssh
- A connected SshClientjava.io.IOException
com.sshtools.common.permissions.PermissionDeniedException
public void setWindowSpace(int windowSpace)
public void setPacketSize(int packetSize)
public void put(java.lang.String localFile, java.lang.String remoteFile, boolean recursive) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, com.sshtools.common.sftp.SftpStatusException, java.io.IOException, com.sshtools.common.permissions.PermissionDeniedException
Uploads a local file onto the remote server.
Treats localFile as a glob regular expression, and puts the files that match into the remote directory.
Code examples can be found in ScpConnect.java
Code Example
//put all .doc files with 'rfc' in their names, in the 'docs/unsorted/' folder relative to the local cwd, and copy them to remoteFile. If remoteFile is a filename then the remote file will have this name unless multiple local files are matched in which case an exception will be thrown. scp.put("docs/unsorted/*rfc*.doc");
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 recursivlycom.sshtools.common.ssh.SshException
- if an IO error occurs during the operationcom.sshtools.common.sftp.SftpStatusException
com.sshtools.common.permissions.PermissionDeniedException
java.io.IOException
com.sshtools.common.ssh.ChannelOpenException
public void putFile(java.lang.String localFile, java.lang.String remoteFile, boolean recursive, FileTransferProgress progress, boolean remoteIsDir) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, java.io.IOException, com.sshtools.common.permissions.PermissionDeniedException
localFile
- remoteFile
- recursive
- progress
- remoteIsDir
- if called by put(string[]...) then remoteFile must be
a directory so need -d option.com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
com.sshtools.common.permissions.PermissionDeniedException
java.io.IOException
public void put(java.lang.String localFileRegExp, java.lang.String remoteFile, boolean recursive, FileTransferProgress progress) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, com.sshtools.common.sftp.SftpStatusException, java.io.IOException, com.sshtools.common.permissions.PermissionDeniedException
localFileRegExp
- remoteFile
- recursive
- progress
- com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
com.sshtools.common.permissions.PermissionDeniedException
java.io.IOException
com.sshtools.common.sftp.SftpStatusException
public void put(java.lang.String[] localFiles, java.lang.String remoteFile, boolean recursive) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, java.io.IOException, com.sshtools.common.permissions.PermissionDeniedException
Uploads an array of local files onto the remote server.
localFiles
- an array of local files; may be files or directoriesremoteFile
- the path on the remote server, may be a file or
directory.recursive
- Copy the contents of directorys recursivlycom.sshtools.common.permissions.PermissionDeniedException
java.io.IOException
- if an IO error occurs during the operationcom.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
public void put(java.lang.String[] localFiles, java.lang.String remoteFile, boolean recursive, FileTransferProgress progress) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, java.io.IOException, com.sshtools.common.permissions.PermissionDeniedException
Uploads an array of local files onto the remote server.
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 recursivlycom.sshtools.common.permissions.PermissionDeniedException
java.io.IOException
- if an IO error occurs during the operationcom.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
public void get(java.lang.String localDir, java.lang.String[] remoteFiles, boolean recursive) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, java.io.IOException, com.sshtools.common.permissions.PermissionDeniedException
Downloads an array of remote files to the local computer.
localDir
- The local path to place the filesremoteFiles
- The path of the remote filesrecursive
- recursively copy the contents of a directorycom.sshtools.common.permissions.PermissionDeniedException
java.io.IOException
- if an IO error occurs during the operationcom.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
public void get(java.lang.String localFile, java.lang.String[] remoteFiles, boolean recursive, FileTransferProgress progress) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, java.io.IOException, com.sshtools.common.permissions.PermissionDeniedException
com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
java.io.IOException
com.sshtools.common.permissions.PermissionDeniedException
public void get(java.lang.String localFile, java.lang.String remoteFile, boolean recursive) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, java.io.IOException, com.sshtools.common.permissions.PermissionDeniedException
Downloads a remote file onto the local computer.
localFile
- The path to place the fileremoteFile
- The path of the file on the remote serverrecursive
- recursivly copy the contents of a directorycom.sshtools.common.permissions.PermissionDeniedException
java.io.IOException
- if an IO error occurs during the operationcom.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
public void get(java.lang.String localFile, java.lang.String remoteFile, boolean recursive, FileTransferProgress progress) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, java.io.IOException, com.sshtools.common.permissions.PermissionDeniedException
com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
java.io.IOException
com.sshtools.common.permissions.PermissionDeniedException
public void exit() throws com.sshtools.common.ssh.SshException, java.io.IOException
com.sshtools.common.ssh.SshException
java.io.IOException
Copyright © 2023. All rights reserved.