com.jcraft.jsch
Class ChannelSftp

java.lang.Object
  extended by com.jcraft.jsch.Channel
      extended by com.jcraft.jsch.ChannelSftp
All Implemented Interfaces:
Runnable

public class ChannelSftp
extends Channel

A Channel connected to an sftp server (as a subsystem of the ssh server).

This class supports the client side of the sftp protocol, version 3, and implements an interface similar to the usual sftp command line client.

The Sftp class in the examples directory implements a command line client based on this class.

Current directory

This sftp client has the concept of a current local directory and a current remote directory. These are not inherent to the protocol, but are used implicitely for all path-based commands sent to the server (for the remote directory) or accessing the local file system (for the local directory).

They can be queried by lpwd() and pwd(), and changed by cd(dir) and lcd(dir).

See Also:
RFC 4254, section 6.5. Starting a Shell or a Command, Internet Draft "SSH File Transfer Protocol" (version 02 describing version 3 of the protocol)

Nested Class Summary
 class ChannelSftp.LsEntry
          Represents a directory entry, representing a remote file or directory.
 
Field Summary
protected  boolean agent_forwarding
           
static int APPEND
          file transfer mode: append to existing file, if any.
protected  Hashtable env
           
static int OVERWRITE
          file transfer mode: overwrite the existing file, if any.
protected  boolean pty
           
static int RESUME
          file transfer mode: resume an interrupted upload/download.
static int SSH_FX_BAD_MESSAGE
           
static int SSH_FX_CONNECTION_LOST
           
static int SSH_FX_EOF
           
static int SSH_FX_FAILURE
           
static int SSH_FX_NO_CONNECTION
           
static int SSH_FX_NO_SUCH_FILE
           
static int SSH_FX_OK
           
static int SSH_FX_OP_UNSUPPORTED
           
static int SSH_FX_PERMISSION_DENIED
           
protected  int tcol
           
protected  byte[] terminal_mode
           
protected  int thp
           
protected  int trow
           
protected  String ttype
           
protected  int twp
           
protected  boolean xforwading
           
 
Fields inherited from class com.jcraft.jsch.Channel
type
 
Method Summary
 void _put(InputStream src, String dst, SftpProgressMonitor monitor, int mode)
          Not for external use.
 void cd(String path)
          Changes the current remote directory.
 void chgrp(int gid, String path)
          Changes the owner group of one or several remote files.
 void chmod(int permissions, String path)
          Changes the permissions of one or several remote files.
 void chown(int uid, String path)
          Changes the owning user of one or several remote files.
 void disconnect()
          closes this channel.
 void exit()
          Exits the Channel.
 InputStream get(String src)
          Starts downloading a file as an InputStream.
 InputStream get(String src, int mode)
          Deprecated. This method will be deleted in the future. A transfer mode is not meaningful here, as you can't really overwrite or append an InputStream.
 void get(String src, OutputStream dst)
          Downloads a file to an OutputStream.
 void get(String src, OutputStream dst, SftpProgressMonitor monitor)
          Downloads a file to an OutputStream.
 void get(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip)
          Downloads a file to an OutputStream.
 InputStream get(String src, SftpProgressMonitor monitor)
          Starts downloading a file as an InputStream.
 InputStream get(String src, SftpProgressMonitor monitor, int mode)
          Deprecated. This method will be deleted in the future. A transfer mode is not meaningful here, as you can't really overwrite or append an InputStream.
 InputStream get(String src, SftpProgressMonitor monitor, long skip)
          Starts downloading a file as an InputStream.
 void get(String src, String dst)
          Downloads a file.
 void get(String src, String dst, SftpProgressMonitor monitor)
          Downloads a file.
 void get(String src, String dst, SftpProgressMonitor monitor, int mode)
          Downloads a file.
 int getBulkRequests()
           
 String getExtension(String key)
          returns the extension data sent by the server corresponding to some extension name.
 String getHome()
          returns the absolute path of the remote home directory.
 int getServerVersion()
          returns the server's protocol version number.
 void lcd(String path)
          Changes the current local directory.
 String lpwd()
          returns the current local directory in absolute form.
 Vector ls(String path)
          lists the contents of a remote directory.
 SftpATTRS lstat(String path)
          Retrieves the file attributes of a file or directory.
 void mkdir(String path)
          creates a new remote directory.
 void put(InputStream src, String dst)
          Uploads a file from an input stream.
 void put(InputStream src, String dst, int mode)
          Uploads a file from an input stream.
 void put(InputStream src, String dst, SftpProgressMonitor monitor)
          Uploads a file from an input stream.
 void put(InputStream src, String dst, SftpProgressMonitor monitor, int mode)
          Uploads a file from an input stream.
 OutputStream put(String dst)
          Starts an upload by OutputStream.
 OutputStream put(String dst, int mode)
          Starts an upload by OutputStream.
 OutputStream put(String dst, SftpProgressMonitor monitor, int mode)
          Starts an upload by OutputStream.
 OutputStream put(String dst, SftpProgressMonitor monitor, int mode, long offset)
          Starts an upload by OutputStream.
 void put(String src, String dst)
          Uploads a file.
 void put(String src, String dst, int mode)
          Uploads a file.
 void put(String src, String dst, SftpProgressMonitor monitor)
          Uploads a file.
 void put(String src, String dst, SftpProgressMonitor monitor, int mode)
          Uploads a file.
 String pwd()
          returns the current remote directory in absolute form.
 void quit()
          Quits the Channel.
 String readlink(String path)
          reads a symbolic link.
 String realpath(String path)
          converts a remote path to its absolute (and to a certain degree canonical) version.
 void rename(String oldpath, String newpath)
          Renames a file or directory.
 void rm(String path)
          removes one or several files.
 void rmdir(String path)
          Removes one or several remote directories.
 void run()
          not to be called by the application.
protected  void sendRequests()
          creates and sends all requests indicated by the properties agentForwarding, xForwarding, pty (and ptyType) and env.
 void setAgentForwarding(boolean enable)
          Enable the agent forwarding.
 void setBulkRequests(int bulk_requests)
           
 void setEnv(byte[] name, byte[] value)
          Set the environment variable.
 void setEnv(Hashtable env)
          Deprecated. Use setEnv(String, String) or setEnv(byte[], byte[]) instead.
 void setEnv(String name, String value)
          Set the environment variable.
 void setFilenameEncoding(String encoding)
          Sets the encoding used to convert file names from Strings to bytes.
 void setMtime(String path, int mtime)
          sets the modification time of one or several remote files.
 void setPty(boolean enable)
          Allocate a Pseudo-Terminal.
 void setPtySize(int col, int row, int wp, int hp)
          Change the window dimension interactively.
 void setPtyType(String ttype)
          Set the terminal type.
 void setPtyType(String ttype, int col, int row, int wp, int hp)
          Set the terminal type.
 void setStat(String path, SftpATTRS attr)
          Changes attributes of a remote file or directory.
 void setTerminalMode(byte[] terminal_mode)
          Set the terminal mode.
 void setXForwarding(boolean enable)
          Enable the X11 forwarding.
 void start()
          Not to be called externally.
 SftpATTRS stat(String path)
          Retrieves the file attributes of a file or directory.
 void symlink(String oldpath, String newpath)
          Creates a new symbolic link.
 String version()
          returns the protocol version number supported by this client.
 
Methods inherited from class com.jcraft.jsch.Channel
connect, connect, getExitStatus, getExtInputStream, getId, getInputStream, getOutputStream, getSession, isClosed, isConnected, isEOF, sendOpenConfirmation, sendOpenFailure, sendSignal, setExtOutputStream, setExtOutputStream, setInputStream, setInputStream, setOutputStream, setOutputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SSH_FX_OK

public static final int SSH_FX_OK
See Also:
Constant Field Values

SSH_FX_EOF

public static final int SSH_FX_EOF
See Also:
Constant Field Values

SSH_FX_NO_SUCH_FILE

public static final int SSH_FX_NO_SUCH_FILE
See Also:
Constant Field Values

SSH_FX_PERMISSION_DENIED

public static final int SSH_FX_PERMISSION_DENIED
See Also:
Constant Field Values

SSH_FX_FAILURE

public static final int SSH_FX_FAILURE
See Also:
Constant Field Values

SSH_FX_BAD_MESSAGE

public static final int SSH_FX_BAD_MESSAGE
See Also:
Constant Field Values

SSH_FX_NO_CONNECTION

public static final int SSH_FX_NO_CONNECTION
See Also:
Constant Field Values

SSH_FX_CONNECTION_LOST

public static final int SSH_FX_CONNECTION_LOST
See Also:
Constant Field Values

SSH_FX_OP_UNSUPPORTED

public static final int SSH_FX_OP_UNSUPPORTED
See Also:
Constant Field Values

OVERWRITE

public static final int OVERWRITE
file transfer mode: overwrite the existing file, if any.

See Also:
Constant Field Values

RESUME

public static final int RESUME
file transfer mode: resume an interrupted upload/download. This transfers only the part of the source file which is beyond the existing destination file's length.

See Also:
Constant Field Values

APPEND

public static final int APPEND
file transfer mode: append to existing file, if any.

See Also:
Constant Field Values

agent_forwarding

protected boolean agent_forwarding

xforwading

protected boolean xforwading

env

protected Hashtable env

pty

protected boolean pty

ttype

protected String ttype

tcol

protected int tcol

trow

protected int trow

twp

protected int twp

thp

protected int thp

terminal_mode

protected byte[] terminal_mode
Method Detail

setBulkRequests

public void setBulkRequests(int bulk_requests)
                     throws JSchException
Throws:
JSchException

getBulkRequests

public int getBulkRequests()

start

public void start()
           throws JSchException
Description copied from class: Channel
Not to be called externally. This method is called by Channel.connect(int) when the connection is established. This implementation here does nothing, but it is overridden in some subclasses.

Overrides:
start in class Channel
Throws:
JSchException

quit

public void quit()
Quits the Channel. This is a synonym to disconnect().


exit

public void exit()
Exits the Channel. This is a synonym to disconnect().


lcd

public void lcd(String path)
         throws SftpException
Changes the current local directory. (This is not sent to the remote side.)

Parameters:
path - a directory path, absolute or relative to the current local path.
Throws:
SftpException - if the mentioned path is not a directory.

cd

public void cd(String path)
        throws SftpException
Changes the current remote directory. This checks the existence and accessibility of the indicated directory, and changes the current remote directory setting.

Parameters:
path - a directory path, absolute or relative to the current remote path.
Throws:
SftpException - if the named path does not indicate a directory, if it is not accessible by the user, or some other problem occurs.

put

public void put(String src,
                String dst)
         throws SftpException
Uploads a file. This uses the OVERWRITE mode, and no progress monitor.

Parameters:
src - the local source file name, absolute or relative to the current local directory.
dst - the remote destination file name, absolute or relative to the current remote directory.
Throws:
SftpException
See Also:
put(String,String,SftpProgressMonitor,int)

put

public void put(String src,
                String dst,
                int mode)
         throws SftpException
Uploads a file. This uses no progress monitor.

Parameters:
src - the local source file name, absolute or relative to the current local directory.
dst - the remote destination file name, absolute or relative to the current remote directory.
mode - the transfer mode, one of RESUME, APPEND, OVERWRITE.
Throws:
SftpException - if some problem occurred.
See Also:
put(String,String,SftpProgressMonitor,int)

put

public void put(String src,
                String dst,
                SftpProgressMonitor monitor)
         throws SftpException
Uploads a file. This uses the OVERWRITE mode.

Parameters:
src - the local source file name, absolute or relative to the current local directory.
dst - the remote destination file name, absolute or relative to the current remote directory.
monitor - an object receiving notifications about the progress of the operation. Can be null, then there will be no progress notification.
Throws:
SftpException - if some problem occurred.
See Also:
put(String,String,SftpProgressMonitor,int)

put

public void put(String src,
                String dst,
                SftpProgressMonitor monitor,
                int mode)
         throws SftpException
Uploads a file.

Parameters:
src - the local source file name, absolute or relative to the current local directory.
dst - the remote destination file name, absolute or relative to the current remote directory.
monitor - an object receiving notifications about the progress of the operation. Can be null, then there will be no progress notification.
mode - the transfer mode, one of RESUME, APPEND, OVERWRITE.
Throws:
SftpException - if some problem occurred.

put

public void put(InputStream src,
                String dst)
         throws SftpException
Uploads a file from an input stream. We use OVERWRITE mode and no progress monitor.

Parameters:
src - the source file, in form of an input stream.
dst - the remote destination file name, relative to the current remote directory.
Throws:
SftpException - if some problem occurred.
See Also:
put(InputStream, String, SftpProgressMonitor, int)

put

public void put(InputStream src,
                String dst,
                int mode)
         throws SftpException
Uploads a file from an input stream. We use no progress monitor.

Parameters:
src - the source file, in form of an input stream.
dst - the remote destination file name, relative to the current remote directory.
mode - the transfer mode, one of RESUME, APPEND, OVERWRITE.
Throws:
SftpException - if some problem occurred.
See Also:
put(InputStream, String, SftpProgressMonitor, int)

put

public void put(InputStream src,
                String dst,
                SftpProgressMonitor monitor)
         throws SftpException
Uploads a file from an input stream. We use OVERWRITE mode.

Parameters:
src - the source file, in form of an input stream.
dst - the remote destination file name, relative to the current remote directory.
monitor - an object receiving notifications about the progress of the operation. Can be null, then there will be no progress notification.
Throws:
SftpException - if some problem occurred.
See Also:
put(InputStream, String, SftpProgressMonitor, int)

put

public void put(InputStream src,
                String dst,
                SftpProgressMonitor monitor,
                int mode)
         throws SftpException
Uploads a file from an input stream.

Parameters:
src - the source file, in form of an input stream.
dst - the remote destination file name, relative to the current remote directory.
monitor - an object receiving notifications about the progress of the operation. Can be null, then there will be no progress notification.
mode - the transfer mode, one of RESUME, APPEND, OVERWRITE.
Throws:
SftpException - if some problem occurred.

_put

public void _put(InputStream src,
                 String dst,
                 SftpProgressMonitor monitor,
                 int mode)
          throws SftpException
Not for external use. The implementation of all the put methods, without some of the checks. This method should not be public.

Throws:
SftpException

put

public OutputStream put(String dst)
                 throws SftpException
Starts an upload by OutputStream. We use OVERWRITE mode, no progress monitor and an offset of 0.

Parameters:
dst - the remote destination file name, relative to the current remote directory.
Returns:
an OutputStream to which the application should write the file contents.
Throws:
SftpException - if some problem occurred.
See Also:
put(String, SftpProgressMonitor, int, long)

put

public OutputStream put(String dst,
                        int mode)
                 throws SftpException
Starts an upload by OutputStream. We use no progress monitor and an offset of 0.

Parameters:
dst - the remote destination file name, relative to the current remote directory.
mode - the transfer mode, one of RESUME, APPEND, OVERWRITE.
Returns:
an OutputStream to which the application should write the file contents.
Throws:
SftpException - if some problem occurred.
See Also:
put(String, SftpProgressMonitor, int, long)

put

public OutputStream put(String dst,
                        SftpProgressMonitor monitor,
                        int mode)
                 throws SftpException
Starts an upload by OutputStream. We use an offset of 0.

Parameters:
dst - the remote destination file name, relative to the current remote directory.
monitor - an object receiving notifications about the progress of the operation. Can be null, then there will be no progress notification.
mode - the transfer mode, one of RESUME, APPEND, OVERWRITE.
Returns:
an OutputStream to which the application should write the file contents.
Throws:
SftpException - if some problem occurred.
See Also:
put(String, SftpProgressMonitor, int, long)

put

public OutputStream put(String dst,
                        SftpProgressMonitor monitor,
                        int mode,
                        long offset)
                 throws SftpException
Starts an upload by OutputStream.

The returned output stream should be used by the application to write data, which will then be uploaded to the remote file. Closing the stream will finish the upload.

Parameters:
dst - the remote destination file name, relative to the current remote directory.
monitor - an object receiving notifications about the progress of the operation. Can be null, then there will be no progress notification.
mode - the transfer mode, one of RESUME, APPEND, OVERWRITE.
offset - the position in the remote file where we want to start writing. In the RESUME and APPEND modes, this is added to the current size of the file (i.e. then a value > 0 creates a sparse section in the file). (I hope I did understand this right - there is no example using this method with offset.)
Returns:
an OutputStream to which the application should write the file contents.
Throws:
SftpException - if some problem occurred.

get

public void get(String src,
                String dst)
         throws SftpException
Downloads a file. This uses OVERWRITE mode and no progress monitor.

Throws:
SftpException
See Also:
get(String, String, SftpProgressMonitor, int)

get

public void get(String src,
                String dst,
                SftpProgressMonitor monitor)
         throws SftpException
Downloads a file. This uses OVERWRITE mode.

Throws:
SftpException
See Also:
get(String, String, SftpProgressMonitor, int)

get

public void get(String src,
                String dst,
                SftpProgressMonitor monitor,
                int mode)
         throws SftpException
Downloads a file.

Parameters:
src - the source file name, relative to the current remote directory.
dst - the destination file name, relative to the current local directory.
monitor - an object receiving notifications about the progress of the operation. Can be null, then there will be no progress notification.
mode - the transfer mode, one of RESUME, APPEND, OVERWRITE.
Throws:
SftpException - if some problem occurred.

get

public void get(String src,
                OutputStream dst)
         throws SftpException
Downloads a file to an OutputStream. This uses OVERWRITE mode and no progress monitor.

Throws:
SftpException
See Also:
get(String, OutputStream, SftpProgressMonitor, int, long)

get

public void get(String src,
                OutputStream dst,
                SftpProgressMonitor monitor)
         throws SftpException
Downloads a file to an OutputStream. This uses OVERWRITE mode.

Throws:
SftpException
See Also:
get(String, OutputStream, SftpProgressMonitor, int, long)

get

public void get(String src,
                OutputStream dst,
                SftpProgressMonitor monitor,
                int mode,
                long skip)
         throws SftpException
Downloads a file to an OutputStream.

Parameters:
src - the source file name, relative to the current remote directory.
dst - the destination output stream.
monitor - an object receiving notifications about the progress of the operation. Can be null, then there will be no progress notification.
mode - the transfer mode, one of RESUME, APPEND, OVERWRITE. The difference is that RESUME mode uses the skip argument, while OVERWRITE and APPEND ignore it.
skip - the position in the remote file where we should start the download, if we are in RESUME mode.
Throws:
SftpException - if some problem occurred.

get

public InputStream get(String src)
                throws SftpException
Starts downloading a file as an InputStream. This uses no progress monitor and a skip of 0.

Throws:
SftpException
See Also:
get(String, SftpProgressMonitor, long)

get

public InputStream get(String src,
                       SftpProgressMonitor monitor)
                throws SftpException
Starts downloading a file as an InputStream. This uses a skip of 0.

Throws:
SftpException
See Also:
get(String, SftpProgressMonitor, long)

get

public InputStream get(String src,
                       int mode)
                throws SftpException
Deprecated. This method will be deleted in the future. A transfer mode is not meaningful here, as you can't really overwrite or append an InputStream.

Throws:
SftpException
See Also:
get(String), get(String, SftpProgressMonitor, long)

get

public InputStream get(String src,
                       SftpProgressMonitor monitor,
                       int mode)
                throws SftpException
Deprecated. This method will be deleted in the future. A transfer mode is not meaningful here, as you can't really overwrite or append an InputStream.

Throws:
SftpException
See Also:
get(String, SftpProgressMonitor, long), get(String, SftpProgressMonitor)

get

public InputStream get(String src,
                       SftpProgressMonitor monitor,
                       long skip)
                throws SftpException
Starts downloading a file as an InputStream.

Parameters:
src - the source file name, relative to the current remote directory.
monitor - an object receiving notifications about the progress of the operation. Can be null, then there will be no progress notification.
skip - the position in the remote file where we should start the download.
Returns:
an InputStream from which the contents of the file can be read.
Throws:
SftpException - if some problem occurred.

ls

public Vector ls(String path)
          throws SftpException
lists the contents of a remote directory.

Parameters:
path - a pattern relative to the current remote directory. The pattern can contain glob pattern wildcards (* or ?) in the last component (i.e. after the last /).
Returns:
a vector of ChannelSftp.LsEntry objects.
Throws:
SftpException

readlink

public String readlink(String path)
                throws SftpException
reads a symbolic link.

Parameters:
path - a path relative to the current remote directory, which should correspond to a symbolic link.
Returns:
the link target, relative to the location of the link itself (this could be depending on the server).
Throws:
SftpException
See Also:
Internet draft, 6.10. Dealing with Symbolic links

symlink

public void symlink(String oldpath,
                    String newpath)
             throws SftpException
Creates a new symbolic link.

Note: The protocol draft declares the two parameters in the reverse order (i.e. first linkpath, then targetpath), but because of an erronous implementation in (both sides of) OpenSSH, the de facto protocol is now what is implemented here (first targetpath, then linkpath). If you are speaking to a SFTP server which implements the protocol as specified, you might have to swap the arguments.

Parameters:
oldpath - the path of the link target, relative to the current remote directory
newpath - the path of the link to be created, relative to the current remote directory
Throws:
SftpException
See Also:
Internet draft, 6.10. Dealing with Symbolic links, OpenSSH protocol deviations.

rename

public void rename(String oldpath,
                   String newpath)
            throws SftpException
Renames a file or directory.

Parameters:
oldpath - the old name of the file, relative to the current remote directory.
newpath - the new name of the file, relative to the current remote directory.
Throws:
SftpException
See Also:
Internet draft, 6.5 Removing and Renaming Files

rm

public void rm(String path)
        throws SftpException
removes one or several files.

Parameters:
path - a glob pattern of the files to be removed, relative to the current remote directory.
Throws:
SftpException
See Also:
Internet draft, 6.5 Removing and Renaming Files

chgrp

public void chgrp(int gid,
                  String path)
           throws SftpException
Changes the owner group of one or several remote files.

Parameters:
gid - the identifier of the new group.
path - a glob pattern of the files to be reowned, relative to the current remote directory.
Throws:
SftpException

chown

public void chown(int uid,
                  String path)
           throws SftpException
Changes the owning user of one or several remote files.

Parameters:
uid - the identifier of the new owner.
path - a glob pattern of the files to be reowned, relative to the current remote directory.
Throws:
SftpException

chmod

public void chmod(int permissions,
                  String path)
           throws SftpException
Changes the permissions of one or several remote files.

Parameters:
permissions - the new permission pattern. This may be modified by a current mask before being applied.
path - a glob pattern of the files to be reowned, relative to the current remote directory.
Throws:
SftpException

setMtime

public void setMtime(String path,
                     int mtime)
              throws SftpException
sets the modification time of one or several remote files.

Parameters:
path - a glob pattern of the files to be reowned, relative to the current remote directory.
mtime - the new modification time, in seconds from the unix epoch.
Throws:
SftpException

rmdir

public void rmdir(String path)
           throws SftpException
Removes one or several remote directories.

Parameters:
path - a glob pattern of the directories to be removed, relative to the current remote directory.
Throws:
SftpException

mkdir

public void mkdir(String path)
           throws SftpException
creates a new remote directory.

Parameters:
path - the path of the new directory, relative to the current remote directory.
Throws:
SftpException

stat

public SftpATTRS stat(String path)
               throws SftpException
Retrieves the file attributes of a file or directory. This method does not follow symbolic links (i.e. returns the attributes of the link and not the target).

Parameters:
path - the path of the file or directory, relative to the current remote directory.
Returns:
an SftpAttrs object containing the file's attributes.
Throws:
SftpException
See Also:
lstat(String)

lstat

public SftpATTRS lstat(String path)
                throws SftpException
Retrieves the file attributes of a file or directory. This method follows symbolic links (i.e. returns the attributes of the target and not the link).

Parameters:
path - the path of the file or directory, relative to the current remote directory.
Returns:
an SftpAttrs object containing the file's attributes.
Throws:
SftpException
See Also:
stat(String)

setStat

public void setStat(String path,
                    SftpATTRS attr)
             throws SftpException
Changes attributes of a remote file or directory.

Parameters:
path - the path of the file or directory, relative to the current remote directory.
attr - the attribute set containing the attributes to be changed.
Throws:
SftpException

pwd

public String pwd()
           throws SftpException
returns the current remote directory in absolute form.

Throws:
SftpException
See Also:
cd(java.lang.String)

lpwd

public String lpwd()
returns the current local directory in absolute form.

See Also:
lcd(java.lang.String)

version

public String version()
returns the protocol version number supported by this client.


getHome

public String getHome()
               throws SftpException
returns the absolute path of the remote home directory.

Throws:
SftpException

disconnect

public void disconnect()
closes this channel.

Overrides:
disconnect in class Channel

getServerVersion

public int getServerVersion()
                     throws SftpException
returns the server's protocol version number.

Throws:
SftpException

setFilenameEncoding

public void setFilenameEncoding(String encoding)
                         throws SftpException
Sets the encoding used to convert file names from Strings to bytes. This should be the the same encoding actually used on the server. Note: This method throws an exception if the server's version is greater than 3 and the encoding is not "UTF-8". I have no idea what is the idea behind this. This method is now used nowhere.

Throws:
SftpException

getExtension

public String getExtension(String key)
returns the extension data sent by the server corresponding to some extension name. This method is now used nowhere.


realpath

public String realpath(String path)
                throws SftpException
converts a remote path to its absolute (and to a certain degree canonical) version.

Parameters:
path - a path name, relative to the current local directory.
Returns:
an absolute version of the path (but not resolving symbolic links).
Throws:
SftpException

setAgentForwarding

public void setAgentForwarding(boolean enable)
Enable the agent forwarding.

Parameters:
enable -

setXForwarding

public void setXForwarding(boolean enable)
Enable the X11 forwarding.

Overrides:
setXForwarding in class Channel
Parameters:
enable -
See Also:
RFC4254 6.3.1. Requesting X11 Forwarding

setEnv

public void setEnv(Hashtable env)
Deprecated. Use setEnv(String, String) or setEnv(byte[], byte[]) instead.

See Also:
setEnv(String, String), setEnv(byte[], byte[])

setEnv

public void setEnv(String name,
                   String value)
Set the environment variable. If name and value are needed to be passed to the remote in your faivorite encoding,use setEnv(byte[], byte[]).

Parameters:
name - A name for environment variable.
value - A value for environment variable.
See Also:
RFC4254 6.4 Environment Variable Passing

setEnv

public void setEnv(byte[] name,
                   byte[] value)
Set the environment variable.

Parameters:
name - A name of environment variable.
value - A value of environment variable.
See Also:
setEnv(String, String), RFC4254 6.4 Environment Variable Passing

setPty

public void setPty(boolean enable)
Allocate a Pseudo-Terminal.

Parameters:
enable -
See Also:
RFC4254 6.2. Requesting a Pseudo-Terminal

setTerminalMode

public void setTerminalMode(byte[] terminal_mode)
Set the terminal mode.

Parameters:
terminal_mode -

setPtySize

public void setPtySize(int col,
                       int row,
                       int wp,
                       int hp)
Change the window dimension interactively.

Parameters:
col - terminal width, columns
row - terminal height, rows
wp - terminal width, pixels
hp - terminal height, pixels
See Also:
RFC4254 6.7. Window Dimension Change Message

setPtyType

public void setPtyType(String ttype)
Set the terminal type. This method is not effective after Channel#connect().

Parameters:
ttype - terminal type(for example, "vt100")
See Also:
setPtyType(String, int, int, int, int)

setPtyType

public void setPtyType(String ttype,
                       int col,
                       int row,
                       int wp,
                       int hp)
Set the terminal type. This method is not effective after Channel#connect().

Parameters:
ttype - terminal type(for example, "vt100")
col - terminal width, columns
row - terminal height, rows
wp - terminal width, pixels
hp - terminal height, pixels

sendRequests

protected void sendRequests()
                     throws Exception
creates and sends all requests indicated by the properties agentForwarding, xForwarding, pty (and ptyType) and env.

Throws:
Exception

run

public void run()
not to be called by the application. Runs the main data transfer loop.

Specified by:
run in interface Runnable
Overrides:
run in class Channel


This is a simplified version of the inofficial Javadoc created by PaĆ­lo Ebermann. Have a look at the official homepage.