Class SftpClientTask
- All Implemented Interfaces:
com.sshtools.common.ssh.RequestFuture
,Runnable
SftpRunnable
) should be passed in the constructor.-
Nested Class Summary
Nested classes/interfaces inherited from class com.sshtools.client.tasks.Task
Task.TaskRunnable<T>
-
Field Summary
Fields inherited from class com.sshtools.common.ssh.ConnectionAwareTask
con, lastError
-
Constructor Summary
ConstructorsConstructorDescriptionSftpClientTask
(SshClient ssh) SftpClientTask
(com.sshtools.common.ssh.SshConnection con) Deprecated, for removal: This API element is subject to removal in a future version.SftpClientTask
(com.sshtools.common.ssh.SshConnection con, Task.TaskRunnable<SftpClientTask> runnable) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCustomRoot
(String rootPath) Deprecated, for removal: This API element is subject to removal in a future version.void
Changes the working directory on the remote server, or the user's default directory ifnull
or any empty string is provided as the directory path.void
cdup()
Change the working directory to the parent directoryvoid
Sets the group ID for the file or directory.void
Deprecated.void
Changes the access permissions or modes of the specified file or directory.void
Sets the user ID to owner for the file or directory.protected void
doSftp()
Deprecated, for removal: This API element is subject to removal in a future version.protected final void
doTask()
void
exit()
Close the SFTP client.static String
formatLongname
(SftpFile file) Format a String with the details of the file.static String
formatLongname
(com.sshtools.common.sftp.SftpFileAttributes attrs, String filename) Format a String with the details of the file.com.sshtools.common.sftp.SftpFileAttributes
Download the remote file to the local computercom.sshtools.common.sftp.SftpFileAttributes
Download the remote file to the local computercom.sshtools.common.sftp.SftpFileAttributes
get
(String path, FileTransferProgress progress) Download the remote file to the local computer.com.sshtools.common.sftp.SftpFileAttributes
get
(String path, FileTransferProgress progress, boolean resume) Download the remote file to the local computer.com.sshtools.common.sftp.SftpFileAttributes
get
(String remote, OutputStream local) Download the remote file into an OutputStream.com.sshtools.common.sftp.SftpFileAttributes
get
(String remote, OutputStream local, long position) Download the remote file into an OutputStream.com.sshtools.common.sftp.SftpFileAttributes
get
(String remote, OutputStream local, FileTransferProgress progress) Download the remote file writing it to the specifiedOutputStream
.com.sshtools.common.sftp.SftpFileAttributes
get
(String remote, OutputStream local, FileTransferProgress progress, long position) Download the remote file writing it to the specifiedOutputStream
.com.sshtools.common.sftp.SftpFileAttributes
Download the remote file into the local file.com.sshtools.common.sftp.SftpFileAttributes
Download the remote file into the local file.com.sshtools.common.sftp.SftpFileAttributes
get
(String remote, String local, FileTransferProgress progress) Download the remote file to the local computer.com.sshtools.common.sftp.SftpFileAttributes
get
(String remote, String local, FileTransferProgress progress, boolean resume) Download the remote file to the local computer.getAbsolutePath
(String path) Get the absolute path for a file.Get the default directory (or HOME directory)int
getEOL
(byte[] nl) int
SftpFile[]
Download the remote files to the local computerSftpFile[]
Download the remote files to the local computerSftpFile[]
getFiles
(String remote, FileTransferProgress progress) Download the remote files to the local computer.SftpFile[]
getFiles
(String remote, FileTransferProgress progress, boolean resume) Download the remote files to the local computer.SftpFile[]
Download the remote files into the local file.SftpFile[]
Download the remote files into the local file.SftpFile[]
getFiles
(String remote, String local, FileTransferProgress progress, boolean resume) Download the remote file to the local computer.getInputStream
(String remotefile) Create an InputStream for reading a remote file.getInputStream
(String remotefile, long position) Create an InputStream for reading a remote file.getOutputStream
(String remotefile) Create an OutputStream for writing to a remote file.getRemoteDirectory
(String remotedir, String localdir, boolean recurse, boolean sync, boolean commit, FileTransferProgress progress) Copy the contents of a remote directory to a local directoryint
Returns the instance of the AbstractSftpChannel used by this classgetSymbolicLinkTarget
(String linkpath) Get the target path of a symbolic link.int
boolean
isClosed()
Returns the state of the SFTP client.boolean
Determine whether the file object is pointing to a symbolic link that is pointing to a directory.void
Changes the local working directory.lpwd()
Returns the absolute path to the local working directory.SftpFile[]
ls()
List the contents of the current remote working directory.SftpFile[]
List the contents remote directory.SftpFile[]
matchRemoteFiles
(String remote) Called by getFileMatches() to do regular expression pattern matching on the files in 'remote''s parent directory.void
Creates a new directory on the remote server.void
Create a directory or set of directories.openDirectory
(String path) void
put
(InputStream in, String remote) Upload the contents of an InputStream to the remote computer.void
put
(InputStream in, String remote, long position) Upload the contents of an InputStream to the remote computer.void
put
(InputStream in, String remote, FileTransferProgress progress) Upload a file to the remote computer reading from the specifiedInputStream
.void
put
(InputStream in, String remote, FileTransferProgress progress, long position) Deprecated.void
put
(InputStream in, String remote, FileTransferProgress progress, long position, long length) void
Upload a file to the remote computervoid
Upload a file to the remote computervoid
put
(String local, FileTransferProgress progress) Upload a file to the remote computer.void
put
(String local, FileTransferProgress progress, boolean resume) Upload a file to the remote computer.void
Upload a file to the remote computervoid
Upload a file to the remote computervoid
put
(String local, String remote, FileTransferProgress progress) Upload a file to the remote computer.void
put
(String local, String remote, FileTransferProgress progress, boolean resume) Upload a file to the remote computer.void
Upload the contents of an InputStream to the remote computer.void
Upload files to the remote computervoid
putFiles
(String local, FileTransferProgress progress) Upload files to the remote computervoid
putFiles
(String local, FileTransferProgress progress, boolean resume) Upload files to the remote computervoid
Upload files to the remote computervoid
Upload files to the remote computervoid
putFiles
(String local, String remote, FileTransferProgress progress) Upload files to the remote computer.void
putFiles
(String local, String remote, FileTransferProgress progress, boolean resume) make local copies of some of the variables, then call putfilematches, which calls "put" on each file that matches the regexp local.putLocalDirectory
(String localdir, String remotedir, boolean recurse, boolean sync, boolean commit, FileTransferProgress progress) Copy the contents of a local directory into a remote directory.pwd()
Returns the absolute path name of the current remote working directory.void
quit()
Close the SFTP client.readDirectory
(SftpHandle dir) void
removeCustomRoot
(String rootPath) Deprecated, for removal: This API element is subject to removal in a future version.void
Rename a file on the remote computer.void
Remove a file or directory from the remote computer.void
Remove a file or directory on the remote computer with options to force deletion of existing files and recursion.void
setBlockSize
(int blocksize) Deprecated, for removal: This API element is subject to removal in a future version.void
setBufferSize
(int buffersize) Set the size of the buffer which is used to read from the local file system.void
setForceRemoteEOL
(boolean forceRemoteEOL) Override automatic detection of the remote EOL (any SFTP version).void
setLocalEOL
(int eolMode) Override the default local system EOL for text mode files.void
setMaxAsyncRequests
(int asyncRequests) Deprecated, for removal: This API element is subject to removal in a future version.void
setRegularExpressionSyntax
(int syntax) sets the type of regular expression matching to perform on gets and putsvoid
setRemoteEOL
(int eolMode) When connected to servers running SFTP version 3 (or less) the remote EOL type needs to be explicitly set because there is no reliable way for the client to determine the type of EOL for text files.void
setTransferMode
(int transferMode) Sets the transfer mode for current operations.com.sshtools.common.sftp.SftpFileAttributes
Returns the attributes of the file from the remote computer.com.sshtools.common.sftp.SftpFileAttributes
Returns the attributes of the link from the remote computer.void
Create a symbolic link on the remote computer.int
umask
(int umask) Sets the umask used by this client.void
Sets the umask for this client.
boolean
verifyFiles
(String localFile, String remoteFile) Verify a local and remote file.boolean
verifyFiles
(String localFile, String remoteFile, long offset, long length) Verify a local and remote file.Methods inherited from class com.sshtools.client.tasks.Task
ofRunnable
Methods inherited from class com.sshtools.common.ssh.ConnectionAwareTask
getLastError, run
Methods inherited from class com.sshtools.common.ssh.AbstractRequestFuture
addFutureListener, done, isDone, isSuccess, waitFor, waitForever
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.sshtools.common.ssh.RequestFuture
isDoneAndSuccess
-
Constructor Details
-
SftpClientTask
@Deprecated(forRemoval=true, since="3.1.0") public SftpClientTask(com.sshtools.common.ssh.SshConnection con) Deprecated, for removal: This API element is subject to removal in a future version. -
SftpClientTask
public SftpClientTask(com.sshtools.common.ssh.SshConnection con, Task.TaskRunnable<SftpClientTask> runnable) -
SftpClientTask
-
-
Method Details
-
doTask
- Specified by:
doTask
in classcom.sshtools.common.ssh.ConnectionAwareTask
- Throws:
Throwable
-
doSftp
Deprecated, for removal: This API element is subject to removal in a future version. -
setBlockSize
Deprecated, for removal: This API element is subject to removal in a future version.Sets the block size used when transferring files, defaults to the optimized setting of 32768. You should not increase this value as the remote server may not be able to support higher blocksizes.- Parameters:
blocksize
-
-
getSubsystemChannel
Returns the instance of the AbstractSftpChannel used by this class- Returns:
- the AbstractSftpChannel instance
-
setTransferMode
public void setTransferMode(int transferMode) Sets the transfer mode for current operations. The valid modes are:
#MODE_BINARY
- Files are transferred in binary mode and no processing of text files is performed (default mode).
#MODE_TEXT
- For servers supporting version 4+ of the SFTP protocol files are transferred in text mode. For earlier protocol versions the files are transfered in binary mode but the client performs processing of text; if files are written to the remote server the client ensures that the line endings conform to the remote EOL mode set usingsetRemoteEOL(int)
. For files retrieved from the server the EOL policy is based upon System policy as defined by the "line.seperator" system property.- Parameters:
transferMode
- int
-
setRemoteEOL
public void setRemoteEOL(int eolMode) When connected to servers running SFTP version 3 (or less) the remote EOL type needs to be explicitly set because there is no reliable way for the client to determine the type of EOL for text files. In versions 4+ a mechanism is provided and this setting is overridden.
Valid values for this method are
EOL_CRLF
(default),EOL_CR
, andEOL_LF
.- Parameters:
eolMode
- int
-
setLocalEOL
public void setLocalEOL(int eolMode) Override the default local system EOL for text mode files.
Valid values for this method are
EOL_CRLF
(default),EOL_CR
, andEOL_LF
.- Parameters:
eolMode
- int
-
setForceRemoteEOL
public void setForceRemoteEOL(boolean forceRemoteEOL) Override automatic detection of the remote EOL (any SFTP version). USE WITH CAUTION.- Parameters:
forceRemoteEOL
-
-
getTransferMode
public int getTransferMode()- Returns:
- int
-
setBufferSize
public void setBufferSize(int buffersize) Set the size of the buffer which is used to read from the local file system. This setting is used to optimize the writing of files by allowing for a large chunk of data to be read in one operation from a local file. The previous version simply read each block of data before sending however this decreased performance, this version now reads the file into a temporary buffer in order to reduce the number of local filesystem reads. This increases performance and so this setting should be set to the highest value possible. The default setting is negative which means the entire file will be read into a temporary buffer.- Parameters:
buffersize
-
-
setMaxAsyncRequests
Deprecated, for removal: This API element is subject to removal in a future version.Set the maximum number of asynchronous requests that are outstanding at any one time. This setting is used to optimize the reading and writing of files to/from the remote file system when using the get and put methods. The default for this setting is 100.- Parameters:
asyncRequests
-
-
umask
public int umask(int umask) Sets the umask used by this client.To give yourself full permissions for both files and directories and prevent the group and other users from having access: umask(077); This subtracts 077 from the system defaults for files and directories 666 and 777. Giving a default access permissions for your files of 600 (rw-------) and for directories of 700 (rwx------). To give all access permissions to the group and allow other users read and execute permission: umask(002); This subtracts 002 from the system defaults to give a default access permission for your files of 664 (rw-rw-r--) and for your directories of 775 (rwxrwxr-x). To give the group and other users all access except write access: umask(022); This subtracts 022 from the system defaults to give a default access permission for your files of 644 (rw-r--r--) and for your directories of 755 (rwxr-xr-x).
- Parameters:
umask
-- Returns:
- the previous umask value
-
openFile
public SftpHandle openFile(String fileName) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException - Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
openFile
public SftpHandle openFile(String fileName, int flags) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException - Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
openDirectory
public SftpHandle openDirectory(String path) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException - Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
readDirectory
public List<SftpFile> readDirectory(SftpHandle dir) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException - Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
cd
public void cd(String dir) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Changes the working directory on the remote server, or the user's default directory if
null
or any empty string is provided as the directory path. The user's default directory is typically their home directory but is dependent upon server implementation.- Parameters:
dir
- the new working directory- Throws:
IOException
- if an IO error occurs or the file does not existcom.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
getDefaultDirectory
public String getDefaultDirectory() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshExceptionGet the default directory (or HOME directory)
- Returns:
- String
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
cdup
public void cdup() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshExceptionChange the working directory to the parent directory- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
addCustomRoot
Deprecated, for removal: This API element is subject to removal in a future version.Add a custom file system root path such as "flash:"- Parameters:
rootPath
-
-
removeCustomRoot
Deprecated, for removal: This API element is subject to removal in a future version.Remove a custom file system root path such as "flash:"- Parameters:
rootPath
-
-
mkdir
public void mkdir(String dir) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Creates a new directory on the remote server. This method will throw an exception if the directory already exists. To create directories and disregard any errors use the
mkdirs
method.- Parameters:
dir
- the name of the new directory- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
mkdirs
public void mkdirs(String dir) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Create a directory or set of directories. This method will not fail even if the directories exist. It is advisable to test whether the directory exists before attempting an operation by using stat to return the directories attributes.
- Parameters:
dir
- the path of directories to create.- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
isDirectoryOrLinkedDirectory
public boolean isDirectoryOrLinkedDirectory(SftpFile file) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Determine whether the file object is pointing to a symbolic link that is pointing to a directory.- Returns:
- boolean
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
pwd
public String pwd() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshExceptionReturns the absolute path name of the current remote working directory.
- Returns:
- the absolute path of the remote working directory.
- Throws:
com.sshtools.common.ssh.SshException
com.sshtools.common.sftp.SftpStatusException
-
ls
public SftpFile[] ls() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshExceptionList the contents of the current remote working directory.
Returns a list of SftpFile instances for the current working directory.
- Returns:
- a list of SftpFile for the current working directory
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
ls
public SftpFile[] ls(String path) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException List the contents remote directory.
Returns a list of SftpFile instances for the remote directory.
- Parameters:
path
- the path on the remote server to list- Returns:
- a list of SftpFile for the remote directory
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
lcd
public void lcd(String path) throws com.sshtools.common.sftp.SftpStatusException, IOException, com.sshtools.common.permissions.PermissionDeniedException Changes the local working directory.
- Parameters:
path
- the path to the new working directory- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
lpwd
Returns the absolute path to the local working directory.
- Returns:
- the absolute path of the local working directory.
- Throws:
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String path, FileTransferProgress progress) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote file to the local computer.
- Parameters:
path
- the path to the remote fileprogress
-- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String path, FileTransferProgress progress, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote file to the local computer.
- Parameters:
path
- the path to the remote fileprogress
-resume
- attempt to resume a interrupted download- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String path, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote file to the local computer
- Parameters:
path
- the path to the remote fileresume
- attempt to resume an interrupted download- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String path) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote file to the local computer
- Parameters:
path
- the path to the remote file- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
getSymbolicLinkTarget
public String getSymbolicLinkTarget(String linkpath) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Get the target path of a symbolic link.- Parameters:
linkpath
-- Returns:
- String
- Throws:
com.sshtools.common.ssh.SshException
- if the remote SFTP version is < 3 an exception is thrown as this feature is not supported by previous versions of the protocol.com.sshtools.common.sftp.SftpStatusException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String remote, String local, FileTransferProgress progress) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote file to the local computer. If the paths provided are not absolute the current working directory is used.
- Parameters:
remote
- the path/name of the remote filelocal
- the path/name to place the file on the local computerprogress
-- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String remote, String local, FileTransferProgress progress, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote file to the local computer. If the paths provided are not absolute the current working directory is used.
- Parameters:
remote
- the path/name of the remote filelocal
- the path/name to place the file on the local computerprogress
-resume
- attempt to resume an interrupted download- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
getRemoteNewline
- Throws:
com.sshtools.common.sftp.SftpStatusException
-
getRemoteEOL
public int getRemoteEOL() throws com.sshtools.common.sftp.SftpStatusException- Throws:
com.sshtools.common.sftp.SftpStatusException
-
getEOL
- Throws:
com.sshtools.common.sftp.SftpStatusException
-
getEOL
public int getEOL(byte[] nl) throws com.sshtools.common.sftp.SftpStatusException - Throws:
com.sshtools.common.sftp.SftpStatusException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String remote, String local, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote file into the local file.- Parameters:
remote
-local
-resume
- attempt to resume an interrupted download- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String remote, String local) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote file into the local file.- Parameters:
remote
-local
-- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String remote, OutputStream local, FileTransferProgress progress) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException Download the remote file writing it to the specified
OutputStream
. The OutputStream is closed by this method even if the operation fails.- Parameters:
remote
- the path/name of the remote filelocal
- the OutputStream to writeprogress
-- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
-
setRegularExpressionSyntax
public void setRegularExpressionSyntax(int syntax) sets the type of regular expression matching to perform on gets and puts- Parameters:
syntax
- , NoSyntax for no regular expression matching, GlobSyntax for GlobSyntax, Perl5Syntax for Perl5Syntax
-
matchRemoteFiles
public SftpFile[] matchRemoteFiles(String remote) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Called by getFileMatches() to do regular expression pattern matching on the files in 'remote''s parent directory.- Parameters:
remote
-- Returns:
- SftpFile[]
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String remote, OutputStream local, FileTransferProgress progress, long position) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException Download the remote file writing it to the specified
OutputStream
. The OutputStream is closed by this method even if the operation fails.- Parameters:
remote
- the path/name of the remote filelocal
- the OutputStream to writeprogress
-position
- the position within the file to start reading from- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
-
getInputStream
public InputStream getInputStream(String remotefile, long position) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Create an InputStream for reading a remote file.- Parameters:
remotefile
-position
-- Returns:
- InputStream
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
getInputStream
public InputStream getInputStream(String remotefile) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Create an InputStream for reading a remote file.- Parameters:
remotefile
-- Returns:
- InputStream
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String remote, OutputStream local, long position) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException Download the remote file into an OutputStream.- Parameters:
remote
-local
-position
- the position from which to start reading the remote file- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
-
get
public com.sshtools.common.sftp.SftpFileAttributes get(String remote, OutputStream local) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException Download the remote file into an OutputStream.- Parameters:
remote
-local
-- Returns:
- the downloaded file's attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
-
isClosed
public boolean isClosed()Returns the state of the SFTP client. The client is closed if the underlying session channel is closed. Invoking the
quit
method of this object will close the underlying session channel.- Returns:
- true if the client is still connected, otherwise false
-
put
public void put(String local, FileTransferProgress progress, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload a file to the remote computer.
- Parameters:
local
- the path/name of the local fileprogress
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
put
public void put(String local, FileTransferProgress progress) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload a file to the remote computer.
- Parameters:
local
- the path/name of the local fileprogress
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
put
public void put(String local) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload a file to the remote computer- Parameters:
local
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
put
public void put(String local, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload a file to the remote computer- Parameters:
local
-resume
- attempt to resume after an interrupted transfer- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
put
public void put(String local, String remote, FileTransferProgress progress) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload a file to the remote computer. If the paths provided are not absolute the current working directory is used.
- Parameters:
local
- the path/name of the local fileremote
- the path/name of the destination fileprogress
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
put
public void put(String local, String remote, FileTransferProgress progress, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload a file to the remote computer. If the paths provided are not absolute the current working directory is used.
- Parameters:
local
- the path/name of the local fileremote
- the path/name of the destination fileprogress
-resume
- attempt to resume after an interrupted transfer- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
put
public void put(String local, String remote, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload a file to the remote computer- Parameters:
local
-remote
-resume
- attempt to resume after an interrupted transfer- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
put
public void put(String local, String remote) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload a file to the remote computer- Parameters:
local
-remote
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
put
public void put(InputStream in, String remote, FileTransferProgress progress) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException Upload a file to the remote computer reading from the specified
InputStream
. The InputStream is closed, even if the operation fails.- Parameters:
in
- the InputStream being readremote
- the path/name of the destination fileprogress
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
-
put
@Deprecated public void put(InputStream in, String remote, FileTransferProgress progress, long position) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException Deprecated.- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
-
put
public void put(InputStream in, String remote, FileTransferProgress progress, long position, long length) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException - Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
-
getOutputStream
public OutputStream getOutputStream(String remotefile) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Create an OutputStream for writing to a remote file.- Parameters:
remotefile
-- Returns:
- OutputStream
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
put
public void put(InputStream in, String remote, long position) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException Upload the contents of an InputStream to the remote computer.- Parameters:
in
-remote
-position
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
-
put
public void put(InputStream in, String remote) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException Upload the contents of an InputStream to the remote computer.- Parameters:
in
-remote
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
-
chown
public void chown(String uid, String path) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Sets the user ID to owner for the file or directory.
- Parameters:
uid
- numeric user id of the new ownerpath
- the path to the remote file/directory- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
-
chgrp
public void chgrp(String gid, String path) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Sets the group ID for the file or directory.
- Parameters:
gid
- the numeric group id for the new grouppath
- the path to the remote file/directory- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
chmod
public void chmod(com.sshtools.common.sftp.PosixPermissions permissions, String path) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Changes the access permissions or modes of the specified file or directory.
Modes determine who can read, change or execute a file.
- Parameters:
permissions
- the absolute mode of the file/directorypath
- the path to the file/directory on the remote server- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
- See Also:
-
PosixPermissions
PosixPermissions.PosixPermissionsBuilder
-
chmod
@Deprecated(since="3.1.0") public void chmod(int permissions, String path) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Deprecated.Changes the access permissions or modes of the specified file or directory.
Modes determine who can read, change or execute a file.
Absolute modes are octal numbers specifying the complete list of attributes for the files; you specify attributes by OR'ing together these bits. 0400 Individual read 0200 Individual write 0100 Individual execute (or list directory) 0040 Group read 0020 Group write 0010 Group execute 0004 Other read 0002 Other write 0001 Other execute
Now deprecated, it is recommended
PosixPermissions
andPosixPermissions.PosixPermissionsBuilder
be used instead.- Parameters:
permissions
- the absolute mode of the file/directorypath
- the path to the file/directory on the remote server- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
umask
Sets the umask for this client.
To give yourself full permissions for both files and directories and prevent the group and other users from having access: umask("077"); This subtracts 077 from the system defaults for files and directories 666 and 777. Giving a default access permissions for your files of 600 (rw-------) and for directories of 700 (rwx------). To give all access permissions to the group and allow other users read and execute permission: umask("002"); This subtracts 002 from the system defaults to give a default access permission for your files of 664 (rw-rw-r--) and for your directories of 775 (rwxrwxr-x). To give the group and other users all access except write access: umask("022"); This subtracts 022 from the system defaults to give a default access permission for your files of 644 (rw-r--r--) and for your directories of 755 (rwxr-xr-x).
- Parameters:
umask
-- Throws:
com.sshtools.common.ssh.SshException
-
rename
public void rename(String oldpath, String newpath) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Rename a file on the remote computer.
- Parameters:
oldpath
- the old pathnewpath
- the new path- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
rm
public void rm(String path) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Remove a file or directory from the remote computer.
- Parameters:
path
- the path of the remote file/directory- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
rm
public void rm(String path, boolean force, boolean recurse) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Remove a file or directory on the remote computer with options to force deletion of existing files and recursion.- Parameters:
path
-force
-recurse
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
symlink
public void symlink(String path, String link) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Create a symbolic link on the remote computer.
- Parameters:
path
- the path to the existing filelink
- the new link- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
stat
public com.sshtools.common.sftp.SftpFileAttributes stat(String path) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Returns the attributes of the file from the remote computer.
- Parameters:
path
- the path of the file on the remote computer- Returns:
- the attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
statLink
public com.sshtools.common.sftp.SftpFileAttributes statLink(String path) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Returns the attributes of the link from the remote computer.
- Parameters:
path
- the path of the file on the remote computer- Returns:
- the attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
getAbsolutePath
public String getAbsolutePath(String path) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Get the absolute path for a file.- Parameters:
path
-- Returns:
- String
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
verifyFiles
public boolean verifyFiles(String localFile, String remoteFile) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, IOException, com.sshtools.common.permissions.PermissionDeniedException Verify a local and remote file. Requires a minimum SFTP version of 5 and/or support of the "md5-hash" extension- Parameters:
localFile
-remoteFile
-- Returns:
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
verifyFiles
public boolean verifyFiles(String localFile, String remoteFile, long offset, long length) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, IOException, com.sshtools.common.permissions.PermissionDeniedException Verify a local and remote file. Requires a minimum SFTP version of 5 and/or support of the "md5-hash" extension.- Parameters:
localFile
-remoteFile
-offset
-length
-- Returns:
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
quit
public void quit() throws com.sshtools.common.ssh.SshExceptionClose the SFTP client.
- Throws:
com.sshtools.common.ssh.SshException
-
exit
public void exit() throws com.sshtools.common.ssh.SshExceptionClose the SFTP client.
- Throws:
com.sshtools.common.ssh.SshException
-
putLocalDirectory
public DirectoryOperation putLocalDirectory(String localdir, String remotedir, boolean recurse, boolean sync, boolean commit, FileTransferProgress progress) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Copy the contents of a local directory into a remote directory.- Parameters:
localdir
- the path to the local directoryremotedir
- the remote directory which will receive the contentsrecurse
- recurse through child folderssync
- synchronize the directories by removing files on the remote server that do not exist locallycommit
- actually perform the operation. If false a DirectoryOperation will be returned so that the operation can be evaluated and no actual files will be created/transfered.progress
-- Returns:
- DirectoryOperation
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
formatLongname
public static String formatLongname(SftpFile file) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException Format a String with the details of the file.-rwxr-xr-x 1 mjos staff 348911 Mar 25 14:29 t-filexfer
- Parameters:
file
-- Returns:
- String
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
-
formatLongname
public static String formatLongname(com.sshtools.common.sftp.SftpFileAttributes attrs, String filename) Format a String with the details of the file.-rwxr-xr-x 1 mjos staff 348911 Mar 25 14:29 t-filexfer
- Parameters:
attrs
-filename
-- Returns:
- String
-
getRemoteDirectory
public DirectoryOperation getRemoteDirectory(String remotedir, String localdir, boolean recurse, boolean sync, boolean commit, FileTransferProgress progress) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Copy the contents of a remote directory to a local directory- Parameters:
remotedir
- the remote directory whose contents will be copied.localdir
- the local directory to where the contents will be copiedrecurse
- recurse into child folderssync
- synchronized the directories by removing files and directories that do not exist on the remote server.commit
- actually perform the operation. If false the operation will be processed and a DirectoryOperation will be returned without actually transfering any files.progress
-- Returns:
- DirectoryOperation
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
getFiles
public SftpFile[] getFiles(String remote) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote files to the local computer
When RegExpSyntax is set to NoSyntax the getFiles() methods act identically to the get() methods except for a different return type.
When RegExpSyntax is set to GlobSyntax or Perl5Syntax, getFiles() treats 'remote' as a regular expression, and gets all the files in 'remote''s parent directory that match the pattern. The default parent directory of remote is the remote cwd unless 'remote' contains file seperators(/).
Examples can be found in SftpConnect.java
Code Example:
// change reg exp syntax from default SftpClient.NoSyntax (no reg exp matching) // to SftpClient.GlobSyntax sftp.setRegularExpressionSyntax(SftpClient.GlobSyntax); // get all .doc files with 'rfc' in their names, in the 'docs/unsorted/' folder // relative to the remote cwd, and copy them to the local cwd. sftp.getFiles("docs/unsorted/*rfc*.doc");
- Parameters:
remote
- the regular expression path to the remote file- Returns:
- the downloaded files' attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
getFiles
public SftpFile[] getFiles(String remote, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote files to the local computer
- Parameters:
remote
- the regular expression path to the remote fileresume
- attempt to resume an interrupted download- Returns:
- the downloaded files' attributes
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
getFiles
public SftpFile[] getFiles(String remote, FileTransferProgress progress) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote files to the local computer.
- Parameters:
remote
- the regular expression path to the remote fileprogress
-- Returns:
- SftpFile[]
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
getFiles
public SftpFile[] getFiles(String remote, FileTransferProgress progress, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote files to the local computer.
- Parameters:
remote
- the regular expression path to the remote fileprogress
-resume
- attempt to resume a interrupted download- Returns:
- SftpFile[]
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
getFiles
public SftpFile[] getFiles(String remote, String local) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote files into the local file.- Parameters:
remote
-local
-- Returns:
- SftpFile[]
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
getFiles
public SftpFile[] getFiles(String remote, String local, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote files into the local file.- Parameters:
remote
-local
-resume
- attempt to resume an interrupted download- Returns:
- SftpFile[]
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
getFiles
public SftpFile[] getFiles(String remote, String local, FileTransferProgress progress, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Download the remote file to the local computer. If the paths provided are not absolute the current working directory is used.
- Parameters:
remote
- the regular expression path/name of the remote fileslocal
- the path/name to place the file on the local computerprogress
-- Returns:
- SftpFile[]
- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
putFiles
public void putFiles(String local) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload the contents of an InputStream to the remote computer.
When RegExpSyntax is set to NoSyntax the putFiles() methods act identically to the put() methods except for a different return type.
When RegExpSyntax is set to GlobSyntax or Perl5Syntax, putFiles() treats 'local' as a regular expression, and gets all the files in 'local''s parent directory that match the pattern. The default parent directory of local is the local cwd unless 'local' contains file seperators.
Examples can be found in SftpConnect.java
Code Example:
// change reg exp syntax from default SftpClient.NoSyntax (no reg exp matching) // to SftpClient.GlobSyntax sftp.setRegularExpressionSyntax(SftpClient.GlobSyntax); // put all .doc files with 'rfc' in their names, in the 'docs/unsorted/' folder // relative to the local cwd, and copy them to the remote cwd. sftp.putFiles("docs/unsorted/*rfc*.doc");
- Parameters:
local
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
putFiles
public void putFiles(String local, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload files to the remote computer- Parameters:
local
-resume
- attempt to resume after an interrupted transfer- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
putFiles
public void putFiles(String local, FileTransferProgress progress) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload files to the remote computer
- Parameters:
local
- the regular expression path/name of the local filesprogress
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
putFiles
public void putFiles(String local, FileTransferProgress progress, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload files to the remote computer
- Parameters:
local
- the regular expression path/name of the local filesprogress
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
putFiles
public void putFiles(String local, String remote) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload files to the remote computer- Parameters:
local
-remote
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
putFiles
public void putFiles(String local, String remote, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload files to the remote computer- Parameters:
local
-remote
-resume
- attempt to resume after an interrupted transfer- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
putFiles
public void putFiles(String local, String remote, FileTransferProgress progress) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException Upload files to the remote computer. If the paths provided are not absolute the current working directory is used.
- Parameters:
local
- the regular expression path/name of the local filesremote
- the path/name of the destination fileprogress
-- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
putFiles
public void putFiles(String local, String remote, FileTransferProgress progress, boolean resume) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException, TransferCancelledException, IOException, com.sshtools.common.permissions.PermissionDeniedException make local copies of some of the variables, then call putfilematches, which calls "put" on each file that matches the regexp local.- Parameters:
local
- the regular expression path/name of the local filesremote
- the path/name of the destination fileprogress
-resume
- attempt to resume after an interrupted transfer- Throws:
com.sshtools.common.sftp.SftpStatusException
com.sshtools.common.ssh.SshException
TransferCancelledException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-