Package com.jcraft.jsch
Class ChannelSftp
java.lang.Object
com.jcraft.jsch.Channel
com.jcraft.jsch.ChannelSftp
- All Implemented Interfaces:
java.lang.Runnable
public class ChannelSftp extends Channel
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classChannelSftp.LsEntrystatic interfaceChannelSftp.LsEntrySelectorThis interface will be passed as an argument forlsmethod. -
Field Summary
Fields Modifier and Type Field Description protected booleanagent_forwardingstatic intAPPENDprotected java.util.Hashtable<byte[],byte[]>envstatic intOVERWRITEprotected booleanptystatic intRESUMEstatic intSSH_FX_BAD_MESSAGEstatic intSSH_FX_CONNECTION_LOSTstatic intSSH_FX_EOFstatic intSSH_FX_FAILUREstatic intSSH_FX_NO_CONNECTIONstatic intSSH_FX_NO_SUCH_FILEstatic intSSH_FX_OKstatic intSSH_FX_OP_UNSUPPORTEDstatic intSSH_FX_PERMISSION_DENIEDprotected inttcolprotected byte[]terminal_modeprotected intthpprotected inttrowprotected java.lang.Stringttypeprotected inttwpprotected booleanxforwading -
Constructor Summary
Constructors Constructor Description ChannelSftp() -
Method Summary
Modifier and Type Method Description void_put(java.io.InputStream src, java.lang.String dst, SftpProgressMonitor monitor, int mode)voidcd(java.lang.String path)voidchgrp(int gid, java.lang.String path)voidchmod(int permissions, java.lang.String path)voidchown(int uid, java.lang.String path)voiddisconnect()voidexit()java.io.InputStreamget(java.lang.String src)java.io.InputStreamget(java.lang.String src, int mode)Deprecated.This method will be deleted in the future.java.io.InputStreamget(java.lang.String src, SftpProgressMonitor monitor)java.io.InputStreamget(java.lang.String src, SftpProgressMonitor monitor, int mode)Deprecated.This method will be deleted in the future.java.io.InputStreamget(java.lang.String src, SftpProgressMonitor monitor, long skip)voidget(java.lang.String src, java.io.OutputStream dst)voidget(java.lang.String src, java.io.OutputStream dst, SftpProgressMonitor monitor)voidget(java.lang.String src, java.io.OutputStream dst, SftpProgressMonitor monitor, int mode, long skip)voidget(java.lang.String src, java.lang.String dst)voidget(java.lang.String src, java.lang.String dst, SftpProgressMonitor monitor)voidget(java.lang.String src, java.lang.String dst, SftpProgressMonitor monitor, int mode)intgetBulkRequests()This method will return the value how many requests may be sent at any one time.java.lang.StringgetExtension(java.lang.String key)java.lang.StringgetHome()intgetServerVersion()voidhardlink(java.lang.String oldpath, java.lang.String newpath)voidlcd(java.lang.String path)java.lang.Stringlpwd()java.util.Vector<ChannelSftp.LsEntry>ls(java.lang.String path)voidls(java.lang.String path, ChannelSftp.LsEntrySelector selector)List files specified by the remotepath.SftpATTRSlstat(java.lang.String path)voidmkdir(java.lang.String path)voidput(java.io.InputStream src, java.lang.String dst)voidput(java.io.InputStream src, java.lang.String dst, int mode)voidput(java.io.InputStream src, java.lang.String dst, SftpProgressMonitor monitor)voidput(java.io.InputStream src, java.lang.String dst, SftpProgressMonitor monitor, int mode)Sends data from the input streamsrctodstfile.java.io.OutputStreamput(java.lang.String dst)java.io.OutputStreamput(java.lang.String dst, int mode)java.io.OutputStreamput(java.lang.String dst, SftpProgressMonitor monitor, int mode)java.io.OutputStreamput(java.lang.String dst, SftpProgressMonitor monitor, int mode, long offset)Sends data from the output stream todstfile.voidput(java.lang.String src, java.lang.String dst)voidput(java.lang.String src, java.lang.String dst, int mode)voidput(java.lang.String src, java.lang.String dst, SftpProgressMonitor monitor)voidput(java.lang.String src, java.lang.String dst, SftpProgressMonitor monitor, int mode)Sends data fromsrcfile todstfile.java.lang.Stringpwd()voidquit()java.lang.Stringreadlink(java.lang.String path)java.lang.Stringrealpath(java.lang.String path)voidrename(java.lang.String oldpath, java.lang.String newpath)voidrm(java.lang.String path)voidrmdir(java.lang.String path)voidrun()protected voidsendRequests()voidsetAgentForwarding(boolean enable)Enable the agent forwarding.voidsetBulkRequests(int bulk_requests)Specify how many requests may be sent at any one time.voidsetEnv(byte[] name, byte[] value)Set the environment variable.voidsetEnv(java.lang.String name, java.lang.String value)Set the environment variable.voidsetEnv(java.util.Hashtable<byte[],byte[]> env)Deprecated.UsesetEnv(String, String)orsetEnv(byte[], byte[])instead.voidsetFilenameEncoding(java.lang.String encoding)voidsetMtime(java.lang.String path, int mtime)voidsetPty(boolean enable)Allocate a Pseudo-Terminal.voidsetPtySize(int col, int row, int wp, int hp)Change the window dimension interactively.voidsetPtyType(java.lang.String ttype)Set the terminal type.voidsetPtyType(java.lang.String ttype, int col, int row, int wp, int hp)Set the terminal type.voidsetStat(java.lang.String path, SftpATTRS attr)voidsetTerminalMode(byte[] terminal_mode)Set the terminal mode.voidsetXForwarding(boolean enable)Enable the X11 forwarding.voidstart()SftpATTRSstat(java.lang.String path)SftpStatVFSstatVFS(java.lang.String path)voidsymlink(java.lang.String oldpath, java.lang.String newpath)java.lang.Stringversion()Methods inherited from class com.jcraft.jsch.Channel
connect, connect, genChannelOpenPacket, getExitStatus, getExtInputStream, getId, getInputStream, getOutputStream, getSession, isClosed, isConnected, isEOF, sendChannelOpen, sendOpenConfirmation, sendOpenFailure, sendSignal, setExtOutputStream, setExtOutputStream, setInputStream, setInputStream, setOutputStream, setOutputStreamMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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
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
- Overrides:
startin classChannel- Throws:
JSchException
-
quit
public void quit() -
exit
public void exit() -
lcd
- Throws:
SftpException
-
cd
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- 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 SftpExceptionSends data fromsrcfile todstfile. Themodeshould beOVERWRITE,RESUMEorAPPEND.- Parameters:
src- source filedst- destination filemonitor- progress monitormode- how data should be added to dst- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- 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 SftpExceptionSends data from the input streamsrctodstfile. Themodeshould beOVERWRITE,RESUMEorAPPEND.- Parameters:
src- input streamdst- destination filemonitor- progress monitormode- 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
- Throws:
SftpException
-
put
- 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 SftpExceptionSends data from the output stream todstfile. Themodeshould beOVERWRITE,RESUMEorAPPEND.- Parameters:
dst- destination filemonitor- progress monitormode- how data should be added to dstoffset- data will be added at offset- Returns:
- output stream, which accepts data to be transferred.
- Throws:
SftpException
-
get
- 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
- 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
- Throws:
SftpException
-
get
public java.io.InputStream get(java.lang.String src, SftpProgressMonitor monitor) throws SftpException- Throws:
SftpException
-
get
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 SftpExceptionDeprecated.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
- Throws:
SftpException
-
ls
List files specified by the remotepath. Each files and directories will be passed toLsEntrySelector#select(LsEntry)method, and if that method returnsLsEntrySelector#BREAK, the operation will be canceled immediately.- Throws:
SftpException- Since:
- 0.1.47
- See Also:
ChannelSftp.LsEntrySelector
-
readlink
- Throws:
SftpException
-
symlink
- Throws:
SftpException
-
hardlink
- Throws:
SftpException
-
rename
- Throws:
SftpException
-
rm
- Throws:
SftpException
-
chgrp
- Throws:
SftpException
-
chown
- Throws:
SftpException
-
chmod
- Throws:
SftpException
-
setMtime
- Throws:
SftpException
-
rmdir
- Throws:
SftpException
-
mkdir
- Throws:
SftpException
-
stat
- Throws:
SftpException
-
statVFS
- Throws:
SftpException
-
lstat
- Throws:
SftpException
-
setStat
- Throws:
SftpException
-
pwd
- Throws:
SftpException
-
lpwd
public java.lang.String lpwd() -
version
public java.lang.String version() -
getHome
- Throws:
SftpException
-
disconnect
public void disconnect()- Overrides:
disconnectin classChannel
-
getServerVersion
- Throws:
SftpException
-
setFilenameEncoding
- Throws:
SftpException
-
getExtension
public java.lang.String getExtension(java.lang.String key) -
realpath
- 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:
setXForwardingin classChannel- Parameters:
enable-
-
setEnv
@Deprecated public void setEnv(java.util.Hashtable<byte[],byte[]> env)Deprecated.UsesetEnv(String, String)orsetEnv(byte[], byte[])instead.- See Also:
setEnv(String, String),setEnv(byte[], byte[])
-
setEnv
public void setEnv(java.lang.String name, java.lang.String value)Set the environment variable. Ifnameandvalueare needed to be passed to the remote in your favorite encoding, usesetEnv(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, columnsrow- terminal height, rowswp- terminal width, pixelshp- 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, columnsrow- terminal height, rowswp- terminal width, pixelshp- terminal height, pixels
-
sendRequests
protected void sendRequests() throws java.lang.Exception- Throws:
java.lang.Exception
-
run
public void run()
-