cd
public void cd(String dir)
throws IOException
Changes the working directory on the remote server.
dir
- the new working directory
chgrp
public void chgrp(int gid,
String path)
throws IOException
Sets the group ID for the file or directory.
gid
- the numeric group id for the new grouppath
- the path to the remote file/directory
chmod
public void chmod(int permissions,
String path)
throws IOException
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
permissions
- the absolute mode of the file/directorypath
- the path to the file/directory on the remote server
chown
public void chown(int uid,
String path)
throws IOException
Sets the user ID to owner for the file or directory.
uid
- numeric user id of the new ownerpath
- the path to the remote file/directory
copyLocalDirectory
public DirectoryOperation copyLocalDirectory(String localdir,
String remotedir,
boolean recurse,
boolean sync,
boolean commit,
FileTransferProgress progress)
throws IOException
localdir
- remotedir
- recurse
- sync
- commit
- progress
-
copyRemoteDirectory
public DirectoryOperation copyRemoteDirectory(String remotedir,
String localdir,
boolean recurse,
boolean sync,
boolean commit,
FileTransferProgress progress)
throws IOException
remotedir
- localdir
- recurse
- sync
- commit
- progress
-
get
public FileAttributes get(String remote,
OutputStream local)
throws IOException
get
public FileAttributes get(String remote,
OutputStream local,
FileTransferProgress progress)
throws IOException,
TransferCancelledException
Download the remote file writing it to the specified
OutputStream
. The OutputStream is closed by this mehtod
even if the operation fails.
remote
- the path/name of the remote filelocal
- the OutputStream to writeprogress
-
get
public FileAttributes get(String remote,
String local)
throws IOException
get
public FileAttributes get(String remote,
String local,
FileTransferProgress progress)
throws IOException,
TransferCancelledException
Download the remote file to the local computer. If the paths provided
are not absolute the current working directory is used.
remote
- the path/name of the remote filelocal
- the path/name to place the file on the local computerprogress
-
getAbsolutePath
public String getAbsolutePath(String path)
throws IOException
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.
- true if the client is still connected, otherwise false
lcd
public void lcd(String path)
throws IOException
Changes the local working directory.
path
- the path to the new working directory
lpwd
public String lpwd()
Returns the absolute path to the local working directory.
- the absolute path of the local working directory.
ls
public List ls()
throws IOException
List the contents of the current remote working directory.
Returns a list of
SftpFile
instances for the current
working directory.
- a list of SftpFile for the current working directory
ls
public List ls(String path)
throws IOException
List the contents remote directory.
Returns a list of
SftpFile
instances for the remote
directory.
path
- the path on the remote server to list
- a list of SftpFile for the remote directory
mkdir
public void mkdir(String dir)
throws IOException
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.
dir
- the name of the new directory
mkdirs
public void mkdirs(String dir)
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 the stat
method to return the directories attributes.
dir
- the path of directories to create.
put
public void put(InputStream in,
String remote)
throws IOException
put
public void put(InputStream in,
String remote,
FileTransferProgress progress)
throws IOException,
TransferCancelledException
Upload a file to the remote computer reading from the specified
InputStream
. The InputStream is closed, even if the operation
fails.
in
- the InputStream being readremote
- the path/name of the destination fileprogress
-
put
public void put(String local)
throws IOException
put
public void put(String local,
String remote)
throws IOException
put
public void put(String local,
String remote,
FileTransferProgress progress)
throws IOException,
TransferCancelledException
Upload a file to the remote computer. If the paths provided are not
absolute the current working directory is used.
local
- the path/name of the local fileremote
- the path/name of the destination fileprogress
-
pwd
public String pwd()
Returns the absolute path name of the current remote working directory.
- the absolute path of the remote working directory.
quit
public void quit()
throws IOException
Close the SFTP client.
rename
public void rename(String oldpath,
String newpath)
throws IOException
Rename a file on the remote computer.
oldpath
- the old pathnewpath
- the new path
rm
public void rm(String path)
throws IOException
Remove a file or directory from the remote computer.
path
- the path of the remote file/directory
rm
public void rm(String path,
boolean force,
boolean recurse)
throws IOException
stat
public FileAttributes stat(String path)
throws IOException
Returns the attributes of the file from the remote computer.
path
- the path of the file on the remote computer
symlink
public void symlink(String path,
String link)
throws IOException
Create a symbolic link on the remote computer.
path
- the path to the existing filelink
- the new link
umask
public void umask(String umask)
throws IOException
umask
public int umask(int umask)
Sets the umask used by this client.