Save This Page
Home » j2ssh-0.2.9-src » com.sshtools.j2ssh » [javadoc | source]
com.sshtools.j2ssh
public class: SftpClient [javadoc | source]
java.lang.Object
   com.sshtools.j2ssh.SftpClient

Implements a Secure File Transfer (SFTP) client.

Field Summary
 SftpSubsystemClient sftp     
 String cwd     
 String lcwd     
 int umask     
 int default_permissions     
Constructor:
 SftpClient(SshClient ssh) throws IOException 

    Constructs the SFTP client.

    Parameters:
    ssh - the SshClient instance
    Throws:
    IOException - if an IO error occurs
 SftpClient(SshClient ssh,
    ChannelEventListener eventListener) throws IOException 

    Constructs the SFTP client with a given channel event listener.

    Parameters:
    ssh - the SshClient instance
    eventListener - an event listener implementation
    Throws:
    IOException - if an IO error occurs
Method from com.sshtools.j2ssh.SftpClient Summary:
addEventListener,   cd,   chgrp,   chmod,   chown,   copyLocalDirectory,   copyRemoteDirectory,   get,   get,   get,   get,   get,   get,   getAbsolutePath,   isClosed,   lcd,   lpwd,   ls,   ls,   mkdir,   mkdirs,   put,   put,   put,   put,   put,   put,   pwd,   quit,   rename,   rm,   rm,   stat,   symlink,   umask,   umask
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sshtools.j2ssh.SftpClient Detail:
 public  void addEventListener(ChannelEventListener eventListener) 
 public  void cd(String dir) throws IOException 

    Changes the working directory on the remote server.

 public  void chgrp(int gid,
    String path) throws IOException 

    Sets the group ID for the file or directory.

 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 
 public  void chown(int uid,
    String path) throws IOException 

    Sets the user ID to owner for the file or directory.

 public DirectoryOperation copyLocalDirectory(String localdir,
    String remotedir,
    boolean recurse,
    boolean sync,
    boolean commit,
    FileTransferProgress progress) throws IOException 
 public DirectoryOperation copyRemoteDirectory(String remotedir,
    String localdir,
    boolean recurse,
    boolean sync,
    boolean commit,
    FileTransferProgress progress) throws IOException 
 public FileAttributes get(String path) throws IOException 
 public FileAttributes get(String path,
    FileTransferProgress progress) throws IOException, TransferCancelledException 

    Download the remote file to the local computer.

 public FileAttributes get(String remote,
    String local) throws IOException 
 public FileAttributes get(String remote,
    OutputStream local) throws IOException 
 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.

 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.

 public String getAbsolutePath(String path) throws IOException 
 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.

 public  void lcd(String path) throws IOException 

    Changes the local working directory.

 public String lpwd() 

    Returns the absolute path to the local working directory.

 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.

 public List ls(String path) throws IOException 

    List the contents remote directory.

    Returns a list of SftpFile instances for the remote directory.

 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.

 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.

 public  void put(String local) throws IOException 
 public  void put(String local,
    FileTransferProgress progress) throws IOException, TransferCancelledException 

    Upload a file to the remote computer.

 public  void put(String local,
    String remote) throws IOException 
 public  void put(InputStream in,
    String remote) throws IOException 
 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.

 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.

 public String pwd() 

    Returns the absolute path name of the current remote working directory.

 public  void quit() throws IOException 

    Close the SFTP client.

 public  void rename(String oldpath,
    String newpath) throws IOException 

    Rename a file on the remote computer.

 public  void rm(String path) throws IOException 

    Remove a file or directory from the remote computer.

 public  void rm(String path,
    boolean force,
    boolean recurse) throws IOException 
 public FileAttributes stat(String path) throws IOException 

    Returns the attributes of the file from the remote computer.

 public  void symlink(String path,
    String link) throws IOException 

    Create a symbolic link on the remote computer.

 public int umask(int umask) 
    Sets the umask used by this client.
 public  void umask(String umask) throws IOException