|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sshtools.sftp.AbstractSftpClient
public abstract class AbstractSftpClient
Implements a Secure File Transfer (SFTP) client.
| Field Summary | |
|---|---|
protected SshClient |
ssh
|
protected int |
umask
|
| Fields inherited from interface com.sshtools.sftp.SftpClient |
|---|
EOL_CR, EOL_CRLF, EOL_LF, GlobSyntax, MODE_BINARY, MODE_TEXT, NoSyntax, Perl5Syntax |
| Constructor Summary | |
|---|---|
protected |
AbstractSftpClient(SshClient ssh,
int maxVersion)
|
| Method Summary | |
|---|---|
void |
addCustomRoot(String rootPath)
Add a custom file system root path such as "flash:" |
void |
cd(String dir)
Changes the working directory on the remote server, or the home directory if null or any empty string is provided as the directory
path |
void |
cdup()
Change the working directory to the parent directory |
protected abstract void |
changeGroup(String gid,
String path)
|
protected abstract void |
changeOwner(String uid,
String path)
|
protected abstract void |
changePermissions(String file,
int permissions)
|
void |
chgrp(String gid,
String path)
Sets the group ID for the file or directory. |
void |
chmod(int permissions,
String path)
Changes the access permissions or modes of the specified file or directory. |
void |
chown(String uid,
String path)
Sets the user ID to owner for the file or directory. |
protected abstract void |
close()
|
DirectoryOperation |
copyLocalDirectory(String localdir,
String remotedir,
boolean recurse,
boolean sync,
boolean commit,
FileTransferProgress progress)
Copy the contents of a local directory into a remote remote directory. |
DirectoryOperation |
copyRemoteDirectory(String remotedir,
String localdir,
boolean recurse,
boolean sync,
boolean commit,
FileTransferProgress progress)
Copy the contents of a remote directory to a local directory |
protected abstract void |
createSymbolicLink(String path,
String link)
|
void |
exit()
Close the SFTP client. |
static String |
formatLongname(SftpFile file)
Format a String with the details of the file. |
static String |
formatLongname(SftpFileAttributes attrs,
String filename)
Format a String with the details of the file. |
SftpFileAttributes |
get(String path)
Download the remote file to the local computer |
SftpFileAttributes |
get(String path,
boolean resume)
Download the remote file to the local computer |
SftpFileAttributes |
get(String path,
FileTransferProgress progress)
Download the remote file to the local computer. |
SftpFileAttributes |
get(String path,
FileTransferProgress progress,
boolean resume)
Download the remote file to the local computer. |
SftpFileAttributes |
get(String remote,
OutputStream local)
Download the remote file into an OutputStream. |
SftpFileAttributes |
get(String remote,
OutputStream local,
FileTransferProgress progress)
Download the remote file writing it to the specified OutputStream. |
SftpFileAttributes |
get(String remote,
OutputStream out,
FileTransferProgress progress,
long position)
Download the remote file writing it to the specified OutputStream. |
SftpFileAttributes |
get(String remote,
OutputStream local,
long position)
Download the remote file into an OutputStream. |
SftpFileAttributes |
get(String remote,
String local)
Download the remote file into the local file. |
SftpFileAttributes |
get(String remote,
String local,
boolean resume)
Download the remote file into the local file. |
SftpFileAttributes |
get(String remote,
String local,
FileTransferProgress progress)
Download the remote file to the local computer. |
SftpFileAttributes |
get(String remote,
String local,
FileTransferProgress progress,
boolean resume)
Download the remote file to the local computer. |
String |
getAbsolutePath(String path)
Get the absolute path for a file. |
protected abstract SftpFileAttributes |
getAttributes(String file)
|
protected abstract byte[] |
getCanonicalNewline()
|
String |
getCharsetEncoding()
|
SftpFile |
getFile(String path)
|
SftpFile[] |
getFiles(String remote)
Download the remote files to the local computer |
SftpFile[] |
getFiles(String remote,
boolean resume)
Download the remote files to the local computer |
SftpFile[] |
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[] |
getFiles(String remote,
OutputStream local)
Download the remote files into an OutputStream. |
SftpFile[] |
getFiles(String remote,
OutputStream local,
FileTransferProgress progress)
Download the remote files writing it to the specified OutputStream. |
SftpFile[] |
getFiles(String remote,
OutputStream local,
FileTransferProgress progress,
long position)
make local copies of some of the variables, then call getfilematches, which calls get on each file that matches the regexp remote. |
SftpFile[] |
getFiles(String remote,
OutputStream local,
long position)
Download the remote files into an OutputStream. |
SftpFile[] |
getFiles(String remote,
String local)
Download the remote files into the local file. |
SftpFile[] |
getFiles(String remote,
String local,
boolean resume)
Download the remote files into the local file. |
SftpFile[] |
getFiles(String remote,
String local,
FileTransferProgress progress)
Download the remote file to the local computer. |
SftpFile[] |
getFiles(String remote,
String local,
FileTransferProgress progress,
boolean resume)
make local copies of some of the variables, then call getfilematches, which calls get on each file that matches the regexp remote. |
InputStream |
getInputStream(String remotefile)
Create an InputStream for reading a remote file. |
protected abstract String |
getRealPath(String path)
|
int |
getTransferMode()
|
abstract boolean |
isClosed()
Returns the state of the SFTP client. |
boolean |
isDirectoryOrLinkedDirectory(SftpFile file)
Determine whether the file object is pointing to a symbolic link that is pointing to a directory. |
void |
lcd(String path)
Changes the local working directory. |
String |
lpwd()
Returns the absolute path to the local working directory. |
SftpFile[] |
ls()
List the contents of the current remote working directory. |
protected abstract void |
makeDirectory(String path,
SftpFileAttributes attrs)
|
void |
mkdir(String dir)
Creates a new directory on the remote server. |
void |
mkdirs(String dir)
Create a directory or set of directories. |
protected abstract void |
onInit(int maxVersion)
|
protected abstract SftpFileAttributes |
performDownload(String remote,
OutputStream out,
FileTransferProgress progress,
long position)
|
protected abstract void |
performUpload(InputStream in,
String remotePath,
FileTransferProgress progress,
long position)
|
void |
put(InputStream in,
String remote)
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 specified
InputStream
. |
void |
put(InputStream in,
String remote,
FileTransferProgress progress,
long position)
|
void |
put(InputStream in,
String remote,
long position)
Upload the contents of an InputStream to the remote computer. |
void |
put(String local)
Upload a file to the remote computer |
void |
put(String local,
boolean resume)
Upload a file to the remote computer |
void |
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 |
put(String local,
String remote)
Upload a file to the remote computer |
void |
put(String local,
String remote,
boolean resume)
Upload a file to the remote computer |
void |
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 |
putFiles(InputStream in,
String remote)
Upload the contents of an InputStream to the remote computer. |
void |
putFiles(InputStream in,
String remote,
FileTransferProgress progress)
Upload files to the remote computer reading from the specified
InputStream
. |
void |
putFiles(InputStream in,
String remote,
FileTransferProgress progress,
long position)
|
void |
putFiles(InputStream in,
String remote,
long position)
Upload the contents of an InputStream to the remote computer. |
void |
putFiles(String local)
Upload the contents of an InputStream to the remote computer. |
void |
putFiles(String local,
boolean resume)
Upload files to the remote computer |
void |
putFiles(String local,
FileTransferProgress progress)
Upload files to the remote computer |
void |
putFiles(String local,
FileTransferProgress progress,
boolean resume)
Upload files to the remote computer |
void |
putFiles(String local,
String remote)
Upload files to the remote computer |
void |
putFiles(String local,
String remote,
boolean resume)
Upload files to the remote computer |
void |
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. |
String |
pwd()
Returns the absolute path name of the current remote working directory. |
void |
quit()
Close the SFTP client. |
void |
removeCustomRoot(String rootPath)
Remove a custom file system root path such as "flash:" |
protected abstract void |
removeDirectory(String filename)
|
protected abstract void |
removeFile(String filename)
|
void |
rename(String oldpath,
String newpath)
Rename a file on the remote computer. |
protected abstract void |
renameFile(String from,
String to)
|
protected String |
resolveRemotePath(String path)
returns the canonical form of path, if path doesn't start with one of '/';cwd;a customRoot; or is a WindowsRoot then prepend cwd to path |
void |
rm(String path)
Remove a file or directory from the remote computer. |
void |
rm(String path,
boolean force,
boolean recurse)
Remove a file or directory on the remote computer with options to force deletion of existing files and recursion. |
void |
setRegularExpressionSyntax(int syntax)
sets the type of regular expression matching to perform on gets and puts |
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. |
void |
setTransferMode(int transferMode)
Sets the transfer mode for current operations. |
SftpFileAttributes |
stat(String path)
Returns the attributes of the file from the remote computer. |
void |
symlink(String path,
String link)
Create a symbolic link on the remote computer. |
int |
umask(int umask)
Sets the umask used by this client. |
void |
umask(String umask)
Sets the umask for this client. |
protected void |
verifyConnection()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.sshtools.sftp.SftpClient |
|---|
getDefaultDirectory, getInputStream, getOutputStream, getVersion, ls, setAttributes |
| Field Detail |
|---|
protected SshClient ssh
protected int umask
| Constructor Detail |
|---|
protected AbstractSftpClient(SshClient ssh,
int maxVersion)
throws SshException,
ChannelOpenException,
SftpStatusException
SshException
ChannelOpenException
SftpStatusException| Method Detail |
|---|
protected abstract void onInit(int maxVersion)
throws SshException,
ChannelOpenException,
SftpStatusException
SshException
ChannelOpenException
SftpStatusExceptionpublic void setTransferMode(int transferMode)
SftpClient
Sets the transfer mode for current operations. The valid modes are:
SftpClient.MODE_BINARY - Files are transferred in binary mode and no
processing of text files is performed (default mode).
SftpClient.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 using
SftpClient.setRemoteEOL(int). For files retrieved from the server the EOL
policy is based upon System policy as defined by the "line.seperator"
system property.
setTransferMode in interface SftpClienttransferMode - intpublic String getCharsetEncoding()
getCharsetEncoding in interface SftpClientpublic void setRemoteEOL(int eolMode)
SftpClientWhen 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, and EOL_LF.
setRemoteEOL in interface SftpClienteolMode - intpublic int getTransferMode()
getTransferMode in interface SftpClientpublic int umask(int umask)
SftpClientTo 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).
umask in interface SftpClient
protected abstract SftpFileAttributes getAttributes(String file)
throws SftpStatusException,
SshException
SftpStatusException
SshException
public void cd(String dir)
throws SftpStatusException,
SshException
SftpClient
Changes the working directory on the remote server, or the home directory
if null or any empty string is provided as the directory
path
cd in interface SftpClientdir - the new working directory
SftpStatusException
SshException
public void cdup()
throws SftpStatusException,
SshException
SftpClient
cdup in interface SftpClientSftpStatusException
SshExceptionpublic void addCustomRoot(String rootPath)
SftpClient
addCustomRoot in interface SftpClientpublic void removeCustomRoot(String rootPath)
SftpClient
removeCustomRoot in interface SftpClient
protected String resolveRemotePath(String path)
throws SftpStatusException
path -
SftpStatusException
protected void verifyConnection()
throws SftpStatusException
SftpStatusException
protected abstract void makeDirectory(String path,
SftpFileAttributes attrs)
throws SftpStatusException,
SshException
SftpStatusException
SshException
public void mkdir(String dir)
throws SftpStatusException,
SshException
SftpClient
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.
mkdir in interface SftpClientdir - the name of the new directory
SftpStatusException
SshException
public void mkdirs(String dir)
throws SftpStatusException,
SshException
SftpClientCreate 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.
mkdirs in interface SftpClientdir - the path of directories to create.
SftpStatusException
SshException
public boolean isDirectoryOrLinkedDirectory(SftpFile file)
throws SftpStatusException,
SshException
SftpClient
isDirectoryOrLinkedDirectory in interface SftpClientSftpStatusException
SshExceptionpublic String pwd()
SftpClientReturns the absolute path name of the current remote working directory.
pwd in interface SftpClient
public SftpFile[] ls()
throws SftpStatusException,
SshException
SftpClientList the contents of the current remote working directory.
Returns a list of SftpFile instances for the current working directory.
ls in interface SftpClientSftpStatusException
SshException
public void lcd(String path)
throws SftpStatusException
SftpClientChanges the local working directory.
lcd in interface SftpClientpath - the path to the new working directory
SftpStatusExceptionpublic String lpwd()
SftpClientReturns the absolute path to the local working directory.
lpwd in interface SftpClient
public SftpFileAttributes get(String path,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientDownload the remote file to the local computer.
get in interface SftpClientpath - the path to the remote file
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFileAttributes get(String path,
FileTransferProgress progress,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientDownload the remote file to the local computer.
get in interface SftpClientpath - the path to the remote fileresume - attempt to resume a interrupted download
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFileAttributes get(String path,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientDownload the remote file to the local computer
get in interface SftpClientpath - the path to the remote fileresume - attempt to resume an interrupted download
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFileAttributes get(String path)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientDownload the remote file to the local computer
get in interface SftpClientpath - the path to the remote file
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFileAttributes get(String remote,
String local,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientDownload the remote file to the local computer. If the paths provided are not absolute the current working directory is used.
get in interface SftpClientremote - the path/name of the remote filelocal - the path/name to place the file on the local computer
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
protected abstract byte[] getCanonicalNewline()
throws SftpStatusException
SftpStatusException
public SftpFileAttributes get(String remote,
String local,
FileTransferProgress progress,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientDownload the remote file to the local computer. If the paths provided are not absolute the current working directory is used.
get in interface SftpClientremote - the path/name of the remote filelocal - the path/name to place the file on the local computerresume - attempt to resume an interrupted download
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFileAttributes get(String remote,
OutputStream out,
FileTransferProgress progress,
long position)
throws SftpStatusException,
TransferCancelledException,
SshException
SftpClient
Download the remote file writing it to the specified
OutputStream. The OutputStream is closed by this method even
if the operation fails.
get in interface SftpClientremote - the path/name of the remote fileout - the OutputStream to writeposition - the position within the file to start reading from
SftpStatusException
TransferCancelledException
SshException
protected abstract SftpFileAttributes performDownload(String remote,
OutputStream out,
FileTransferProgress progress,
long position)
throws SftpStatusException,
TransferCancelledException,
SshException
SftpStatusException
TransferCancelledException
SshException
public SftpFileAttributes get(String remote,
String local,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
get in interface SftpClientresume - attempt to resume an interrupted download
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFileAttributes get(String remote,
String local)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
get in interface SftpClientFileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFileAttributes get(String remote,
OutputStream local,
FileTransferProgress progress)
throws SftpStatusException,
SshException,
TransferCancelledException
SftpClient
Download the remote file writing it to the specified
OutputStream. The OutputStream is closed by this method even
if the operation fails.
get in interface SftpClientremote - the path/name of the remote filelocal - the OutputStream to write
SftpStatusException
SshException
TransferCancelledException
public SftpFile[] getFiles(String remote,
OutputStream local,
FileTransferProgress progress,
long position)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
getFiles in interface SftpClientFileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFile[] getFiles(String remote,
String local,
FileTransferProgress progress,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
getFiles in interface SftpClientFileNotFoundException
SftpStatusException
SshException
TransferCancelledExceptionpublic void setRegularExpressionSyntax(int syntax)
SftpClient
setRegularExpressionSyntax in interface SftpClientsyntax - , NoSyntax for no regular expression matching, GlobSyntax for
GlobSyntax, Perl5Syntax for Perl5Syntax
public SftpFile getFile(String path)
throws SshException,
SftpStatusException
getFile in interface SftpClientSshException
SftpStatusException
public InputStream getInputStream(String remotefile)
throws SftpStatusException,
SshException
SftpClient
getInputStream in interface SftpClientSftpStatusException
SshException
public SftpFileAttributes get(String remote,
OutputStream local,
long position)
throws SftpStatusException,
SshException,
TransferCancelledException
SftpClient
get in interface SftpClientposition - the position from which to start reading the remote file
SftpStatusException
SshException
TransferCancelledException
public SftpFileAttributes get(String remote,
OutputStream local)
throws SftpStatusException,
SshException,
TransferCancelledException
SftpClient
get in interface SftpClientSftpStatusException
SshException
TransferCancelledExceptionpublic abstract boolean isClosed()
SftpClient
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.
isClosed in interface SftpClient
public void put(String local,
FileTransferProgress progress,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientUpload a file to the remote computer.
put in interface SftpClientlocal - the path/name of the local file
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void put(String local,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientUpload a file to the remote computer.
put in interface SftpClientlocal - the path/name of the local file
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void put(String local)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
put in interface SftpClientFileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void put(String local,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
put in interface SftpClientresume - attempt to resume after an interrupted transfer
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void put(String local,
String remote,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientUpload a file to the remote computer. If the paths provided are not absolute the current working directory is used.
put in interface SftpClientlocal - the path/name of the local fileremote - the path/name of the destination file
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void put(String local,
String remote,
FileTransferProgress progress,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientUpload a file to the remote computer. If the paths provided are not absolute the current working directory is used.
put in interface SftpClientlocal - the path/name of the local fileremote - the path/name of the destination fileresume - attempt to resume after an interrupted transfer
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void put(String local,
String remote,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
put in interface SftpClientresume - attempt to resume after an interrupted transfer
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void put(String local,
String remote)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
put in interface SftpClientFileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void put(InputStream in,
String remote,
FileTransferProgress progress)
throws SftpStatusException,
SshException,
TransferCancelledException
SftpClient
Upload a file to the remote computer reading from the specified
InputStream
. The InputStream is closed, even if the operation fails.
put in interface SftpClientin - the InputStream being readremote - the path/name of the destination file
SftpStatusException
SshException
TransferCancelledException
public void put(InputStream in,
String remote,
FileTransferProgress progress,
long position)
throws SftpStatusException,
SshException,
TransferCancelledException
put in interface SftpClientSftpStatusException
SshException
TransferCancelledException
protected abstract void performUpload(InputStream in,
String remotePath,
FileTransferProgress progress,
long position)
throws SftpStatusException,
SshException,
TransferCancelledException
SftpStatusException
SshException
TransferCancelledException
public void put(InputStream in,
String remote,
long position)
throws SftpStatusException,
SshException,
TransferCancelledException
SftpClient
put in interface SftpClientSftpStatusException
SshException
TransferCancelledException
public void put(InputStream in,
String remote)
throws SftpStatusException,
SshException,
TransferCancelledException
SftpClient
put in interface SftpClientSftpStatusException
SshException
TransferCancelledException
public void chown(String uid,
String path)
throws SftpStatusException,
SshException
SftpClientSets the user ID to owner for the file or directory.
chown in interface SftpClientuid - numeric user id of the new ownerpath - the path to the remote file/directory
SftpStatusException
SshException
protected abstract void changeOwner(String uid,
String path)
throws SftpStatusException,
SshException
SftpStatusException
SshException
protected abstract void changeGroup(String gid,
String path)
throws SftpStatusException,
SshException
SftpStatusException
SshException
public void chgrp(String gid,
String path)
throws SftpStatusException,
SshException
SftpClientSets the group ID for the file or directory.
chgrp in interface SftpClientgid - the numeric group id for the new grouppath - the path to the remote file/directory
SftpStatusException
SshException
protected abstract void changePermissions(String file,
int permissions)
throws SftpStatusException,
SshException
SftpStatusException
SshException
public void chmod(int permissions,
String path)
throws SftpStatusException,
SshException
SftpClientChanges 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
chmod in interface SftpClientpermissions - the absolute mode of the file/directorypath - the path to the file/directory on the remote server
SftpStatusException
SshException
public void umask(String umask)
throws SshException
SftpClient
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).
umask in interface SftpClientSshException
protected abstract void renameFile(String from,
String to)
throws SftpStatusException,
SshException
SftpStatusException
SshException
public void rename(String oldpath,
String newpath)
throws SftpStatusException,
SshException
SftpClientRename a file on the remote computer.
rename in interface SftpClientoldpath - the old pathnewpath - the new path
SftpStatusException
SshException
protected abstract void removeDirectory(String filename)
throws SftpStatusException,
SshException
SftpStatusException
SshException
protected abstract void removeFile(String filename)
throws SftpStatusException,
SshException
SftpStatusException
SshException
public void rm(String path)
throws SftpStatusException,
SshException
SftpClientRemove a file or directory from the remote computer.
rm in interface SftpClientpath - the path of the remote file/directory
SftpStatusException
SshException
public void rm(String path,
boolean force,
boolean recurse)
throws SftpStatusException,
SshException
SftpClient
rm in interface SftpClientSftpStatusException
SshException
protected abstract void createSymbolicLink(String path,
String link)
throws SftpStatusException,
SshException
SftpStatusException
SshException
public void symlink(String path,
String link)
throws SftpStatusException,
SshException
SftpClientCreate a symbolic link on the remote computer.
symlink in interface SftpClientpath - the path to the existing filelink - the new link
SftpStatusException
SshException
public SftpFileAttributes stat(String path)
throws SftpStatusException,
SshException
SftpClientReturns the attributes of the file from the remote computer.
stat in interface SftpClientpath - the path of the file on the remote computer
SftpStatusException
SshExceptionSftpClient.setAttributes(String, SftpFileAttributes)
protected abstract String getRealPath(String path)
throws SftpStatusException,
SshException
SftpStatusException
SshException
public String getAbsolutePath(String path)
throws SftpStatusException,
SshException
SftpClient
getAbsolutePath in interface SftpClientSftpStatusException
SshException
public void quit()
throws SshException
SftpClientClose the SFTP client.
quit in interface SftpClientSshException
protected abstract void close()
throws SshIOException,
IOException
SshIOException
IOException
public void exit()
throws SshException
SftpClientClose the SFTP client.
exit in interface Clientexit in interface SftpClientSshException
public DirectoryOperation copyLocalDirectory(String localdir,
String remotedir,
boolean recurse,
boolean sync,
boolean commit,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
copyLocalDirectory in interface SftpClientlocaldir - 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.
SftpStatusException
SshException
TransferCancelledException
FileNotFoundException
public static String formatLongname(SftpFile file)
throws SftpStatusException,
SshException
-rwxr-xr-x 1 mjos staff 348911 Mar 25 14:29 t-filexfer
file -
SftpStatusException
SshException
public static String formatLongname(SftpFileAttributes attrs,
String filename)
-rwxr-xr-x 1 mjos staff 348911 Mar 25 14:29 t-filexfer
attrs - filename -
public DirectoryOperation copyRemoteDirectory(String remotedir,
String localdir,
boolean recurse,
boolean sync,
boolean commit,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
copyRemoteDirectory in interface SftpClientremotedir - 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.
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFile[] getFiles(String remote)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientDownload 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");
getFiles in interface SftpClientremote - the regular expression path to the remote file
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFile[] getFiles(String remote,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientDownload the remote files to the local computer
getFiles in interface SftpClientremote - the regular expression path to the remote fileresume - attempt to resume an interrupted download
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFile[] getFiles(String remote,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientDownload the remote files to the local computer.
getFiles in interface SftpClientremote - the regular expression path to the remote file
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFile[] getFiles(String remote,
FileTransferProgress progress,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientDownload the remote files to the local computer.
getFiles in interface SftpClientremote - the regular expression path to the remote fileresume - attempt to resume a interrupted download
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFile[] getFiles(String remote,
OutputStream local)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
getFiles in interface SftpClientSftpStatusException
SshException
TransferCancelledException
FileNotFoundException
public SftpFile[] getFiles(String remote,
OutputStream local,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
Download the remote files writing it to the specified
OutputStream. The OutputStream is closed by this mehtod even
if the operation fails.
getFiles in interface SftpClientremote - the regular expression path/name of the remote filelocal - the OutputStream to write
SftpStatusException
SshException
TransferCancelledException
FileNotFoundException
public SftpFile[] getFiles(String remote,
OutputStream local,
long position)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
getFiles in interface SftpClientposition - the position from which to start reading the remote file
SftpStatusException
SshException
TransferCancelledException
FileNotFoundException
public SftpFile[] getFiles(String remote,
String local)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
getFiles in interface SftpClientFileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFile[] getFiles(String remote,
String local,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
getFiles in interface SftpClientresume - attempt to resume an interrupted download
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public SftpFile[] getFiles(String remote,
String local,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientDownload the remote file to the local computer. If the paths provided are not absolute the current working directory is used.
getFiles in interface SftpClientremote - the regular expression path/name of the remote fileslocal - the path/name to place the file on the local computer
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void putFiles(InputStream in,
String remote)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientUpload the contents of an InputStream to the remote computer.
putFiles in interface SftpClientSftpStatusException
SshException
TransferCancelledException
FileNotFoundException
public void putFiles(InputStream in,
String remote,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
Upload files to the remote computer reading from the specified
InputStream
. The InputStream is closed, even if the operation fails.
putFiles in interface SftpClientin - the InputStream being readremote - the path/name of the destination file
SftpStatusException
SshException
TransferCancelledException
FileNotFoundException
public void putFiles(InputStream in,
String remote,
FileTransferProgress progress,
long position)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
putFiles in interface SftpClientFileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void putFiles(InputStream in,
String remote,
long position)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
putFiles in interface SftpClientSftpStatusException
SshException
TransferCancelledException
FileNotFoundException
public void putFiles(String local)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientUpload 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");
putFiles in interface SftpClientFileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void putFiles(String local,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
putFiles in interface SftpClientresume - attempt to resume after an interrupted transfer
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void putFiles(String local,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientUpload files to the remote computer
putFiles in interface SftpClientlocal - the regular expression path/name of the local files
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void putFiles(String local,
FileTransferProgress progress,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientUpload files to the remote computer
putFiles in interface SftpClientlocal - the regular expression path/name of the local files
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void putFiles(String local,
String remote)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
putFiles in interface SftpClientFileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void putFiles(String local,
String remote,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
putFiles in interface SftpClientresume - attempt to resume after an interrupted transfer
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void putFiles(String local,
String remote,
FileTransferProgress progress)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClientUpload files to the remote computer. If the paths provided are not absolute the current working directory is used.
putFiles in interface SftpClientlocal - the regular expression path/name of the local filesremote - the path/name of the destination file
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
public void putFiles(String local,
String remote,
FileTransferProgress progress,
boolean resume)
throws FileNotFoundException,
SftpStatusException,
SshException,
TransferCancelledException
SftpClient
putFiles in interface SftpClientlocal - the regular expression path/name of the local filesremote - the path/name of the destination fileresume - attempt to resume after an interrupted transfer
FileNotFoundException
SftpStatusException
SshException
TransferCancelledException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||