Class ChannelSftp

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

public class ChannelSftp
extends Channel
  • Field Details

    • 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
      See Also:
      Constant Field Values
    • RESUME

      public static final int RESUME
      See Also:
      Constant Field Values
    • APPEND

      public static final int APPEND
      See Also:
      Constant Field Values
    • agent_forwarding

      protected boolean agent_forwarding
    • xforwading

      protected boolean xforwading
    • env

      protected java.util.Hashtable<byte[],​byte[]> env
    • pty

      protected boolean pty
    • ttype

      protected java.lang.String ttype
    • tcol

      protected int tcol
    • trow

      protected int trow
    • twp

      protected int twp
    • thp

      protected int thp
    • terminal_mode

      protected byte[] terminal_mode
  • Constructor Details

    • ChannelSftp

      public ChannelSftp()
  • Method Details

    • setBulkRequests

      public void setBulkRequests​(int bulk_requests) throws JSchException
      Specify how many requests may be sent at any one time. Increasing this value may slightly improve file transfer speed but will increase memory usage. The default is 16 requests.
      Parameters:
      bulk_requests - how many requests may be outstanding at any one time.
      Throws:
      JSchException
    • getBulkRequests

      public int getBulkRequests()
      This method will return the value how many requests may be sent at any one time.
      Returns:
      how many requests may be sent at any one time.
    • start

      public void start() throws JSchException
      Overrides:
      start in class Channel
      Throws:
      JSchException
    • quit

      public void quit()
    • exit

      public void exit()
    • lcd

      public void lcd​(java.lang.String path) throws SftpException
      Throws:
      SftpException
    • cd

      public void cd​(java.lang.String path) throws SftpException
      Throws:
      SftpException
    • put

      public void put​(java.lang.String src, java.lang.String dst) throws SftpException
      Throws:
      SftpException
    • put

      public void put​(java.lang.String src, java.lang.String dst, int mode) throws SftpException
      Throws:
      SftpException
    • put

      public void put​(java.lang.String src, java.lang.String dst, SftpProgressMonitor monitor) throws SftpException
      Throws:
      SftpException
    • put

      public void put​(java.lang.String src, java.lang.String dst, SftpProgressMonitor monitor, int mode) throws SftpException
      Sends data from src file to dst file. The mode should be OVERWRITE, RESUME or APPEND.
      Parameters:
      src - source file
      dst - destination file
      monitor - progress monitor
      mode - how data should be added to dst
      Throws:
      SftpException
    • put

      public void put​(java.io.InputStream src, java.lang.String dst) throws SftpException
      Throws:
      SftpException
    • put

      public void put​(java.io.InputStream src, java.lang.String dst, int mode) throws SftpException
      Throws:
      SftpException
    • put

      public void put​(java.io.InputStream src, java.lang.String dst, SftpProgressMonitor monitor) throws SftpException
      Throws:
      SftpException
    • put

      public void put​(java.io.InputStream src, java.lang.String dst, SftpProgressMonitor monitor, int mode) throws SftpException
      Sends data from the input stream src to dst file. The mode should be OVERWRITE, RESUME or APPEND.
      Parameters:
      src - input stream
      dst - destination file
      monitor - progress monitor
      mode - how data should be added to dst
      Throws:
      SftpException
    • _put

      public void _put​(java.io.InputStream src, java.lang.String dst, SftpProgressMonitor monitor, int mode) throws SftpException
      Throws:
      SftpException
    • put

      public java.io.OutputStream put​(java.lang.String dst) throws SftpException
      Throws:
      SftpException
    • put

      public java.io.OutputStream put​(java.lang.String dst, int mode) throws SftpException
      Throws:
      SftpException
    • put

      public java.io.OutputStream put​(java.lang.String dst, SftpProgressMonitor monitor, int mode) throws SftpException
      Throws:
      SftpException
    • put

      public java.io.OutputStream put​(java.lang.String dst, SftpProgressMonitor monitor, int mode, long offset) throws SftpException
      Sends data from the output stream to dst file. The mode should be OVERWRITE, RESUME or APPEND.
      Parameters:
      dst - destination file
      monitor - progress monitor
      mode - how data should be added to dst
      offset - data will be added at offset
      Returns:
      output stream, which accepts data to be transferred.
      Throws:
      SftpException
    • get

      public void get​(java.lang.String src, java.lang.String dst) throws SftpException
      Throws:
      SftpException
    • get

      public void get​(java.lang.String src, java.lang.String dst, SftpProgressMonitor monitor) throws SftpException
      Throws:
      SftpException
    • get

      public void get​(java.lang.String src, java.lang.String dst, SftpProgressMonitor monitor, int mode) throws SftpException
      Throws:
      SftpException
    • get

      public void get​(java.lang.String src, java.io.OutputStream dst) throws SftpException
      Throws:
      SftpException
    • get

      public void get​(java.lang.String src, java.io.OutputStream dst, SftpProgressMonitor monitor) throws SftpException
      Throws:
      SftpException
    • get

      public void get​(java.lang.String src, java.io.OutputStream dst, SftpProgressMonitor monitor, int mode, long skip) throws SftpException
      Throws:
      SftpException
    • get

      public java.io.InputStream get​(java.lang.String src) throws SftpException
      Throws:
      SftpException
    • get

      public java.io.InputStream get​(java.lang.String src, SftpProgressMonitor monitor) throws SftpException
      Throws:
      SftpException
    • get

      @Deprecated public java.io.InputStream get​(java.lang.String src, int mode) throws SftpException
      Deprecated.
      This method will be deleted in the future.
      Throws:
      SftpException
    • get

      @Deprecated public java.io.InputStream get​(java.lang.String src, SftpProgressMonitor monitor, int mode) throws SftpException
      Deprecated.
      This method will be deleted in the future.
      Throws:
      SftpException
    • get

      public java.io.InputStream get​(java.lang.String src, SftpProgressMonitor monitor, long skip) throws SftpException
      Throws:
      SftpException
    • ls

      public java.util.Vector<ChannelSftp.LsEntry> ls​(java.lang.String path) throws SftpException
      Throws:
      SftpException
    • ls

      public void ls​(java.lang.String path, ChannelSftp.LsEntrySelector selector) throws SftpException
      List files specified by the remote path. Each files and directories will be passed to LsEntrySelector#select(LsEntry) method, and if that method returns LsEntrySelector#BREAK, the operation will be canceled immediately.
      Throws:
      SftpException
      Since:
      0.1.47
      See Also:
      ChannelSftp.LsEntrySelector
    • readlink

      public java.lang.String readlink​(java.lang.String path) throws SftpException
      Throws:
      SftpException
    • symlink

      public void symlink​(java.lang.String oldpath, java.lang.String newpath) throws SftpException
      Throws:
      SftpException
    • hardlink

      public void hardlink​(java.lang.String oldpath, java.lang.String newpath) throws SftpException
      Throws:
      SftpException
    • rename

      public void rename​(java.lang.String oldpath, java.lang.String newpath) throws SftpException
      Throws:
      SftpException
    • rm

      public void rm​(java.lang.String path) throws SftpException
      Throws:
      SftpException
    • chgrp

      public void chgrp​(int gid, java.lang.String path) throws SftpException
      Throws:
      SftpException
    • chown

      public void chown​(int uid, java.lang.String path) throws SftpException
      Throws:
      SftpException
    • chmod

      public void chmod​(int permissions, java.lang.String path) throws SftpException
      Throws:
      SftpException
    • setMtime

      public void setMtime​(java.lang.String path, int mtime) throws SftpException
      Throws:
      SftpException
    • rmdir

      public void rmdir​(java.lang.String path) throws SftpException
      Throws:
      SftpException
    • mkdir

      public void mkdir​(java.lang.String path) throws SftpException
      Throws:
      SftpException
    • stat

      public SftpATTRS stat​(java.lang.String path) throws SftpException
      Throws:
      SftpException
    • statVFS

      public SftpStatVFS statVFS​(java.lang.String path) throws SftpException
      Throws:
      SftpException
    • lstat

      public SftpATTRS lstat​(java.lang.String path) throws SftpException
      Throws:
      SftpException
    • setStat

      public void setStat​(java.lang.String path, SftpATTRS attr) throws SftpException
      Throws:
      SftpException
    • pwd

      public java.lang.String pwd() throws SftpException
      Throws:
      SftpException
    • lpwd

      public java.lang.String lpwd()
    • version

      public java.lang.String version()
    • getHome

      public java.lang.String getHome() throws SftpException
      Throws:
      SftpException
    • disconnect

      public void disconnect()
      Overrides:
      disconnect in class Channel
    • getServerVersion

      public int getServerVersion() throws SftpException
      Throws:
      SftpException
    • setFilenameEncoding

      public void setFilenameEncoding​(java.lang.String encoding) throws SftpException
      Throws:
      SftpException
    • getExtension

      public java.lang.String getExtension​(java.lang.String key)
    • realpath

      public java.lang.String realpath​(java.lang.String path) throws SftpException
      Throws:
      SftpException
    • setAgentForwarding

      public void setAgentForwarding​(boolean enable)
      Enable the agent forwarding.
      Parameters:
      enable -
    • setXForwarding

      public void setXForwarding​(boolean enable)
      Enable the X11 forwarding. Refer to RFC4254 6.3.1. Requesting X11 Forwarding.
      Overrides:
      setXForwarding in class Channel
      Parameters:
      enable -
    • setEnv

      @Deprecated public void setEnv​(java.util.Hashtable<byte[],​byte[]> env)
      Deprecated.
      See Also:
      setEnv(String, String), setEnv(byte[], byte[])
    • setEnv

      public void setEnv​(java.lang.String name, java.lang.String value)
      Set the environment variable. If name and value are needed to be passed to the remote in your favorite encoding, use setEnv(byte[], byte[]). Refer to RFC4254 6.4 Environment Variable Passing.
      Parameters:
      name - A name for environment variable.
      value - A value for environment variable.
    • setEnv

      public void setEnv​(byte[] name, byte[] value)
      Set the environment variable. Refer to RFC4254 6.4 Environment Variable Passing.
      Parameters:
      name - A name of environment variable.
      value - A value of environment variable.
      See Also:
      setEnv(String, String)
    • setPty

      public void setPty​(boolean enable)
      Allocate a Pseudo-Terminal. Refer to RFC4254 6.2. Requesting a Pseudo-Terminal.
      Parameters:
      enable -
    • 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. Refer to RFC4254 6.7. Window Dimension Change Message.
      Parameters:
      col - terminal width, columns
      row - terminal height, rows
      wp - terminal width, pixels
      hp - terminal height, pixels
    • setPtyType

      public void setPtyType​(java.lang.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​(java.lang.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 java.lang.Exception
      Throws:
      java.lang.Exception
    • run

      public void run()
      Specified by:
      run in interface java.lang.Runnable
      Overrides:
      run in class Channel