Package com.jcraft.jsch
Class ChannelSftp
java.lang.Object
com.jcraft.jsch.Channel
com.jcraft.jsch.ChannelSftp
- All Implemented Interfaces:
Runnable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static interface
This interface will be passed as an argument forls
method. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
static final int
protected Hashtable<byte[],
byte[]> static final int
protected boolean
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
protected int
protected byte[]
protected int
protected int
protected String
protected int
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
_put
(InputStream src, String dst, SftpProgressMonitor monitor, int mode) void
void
void
void
void
void
exit()
Deprecated.This method will be deleted in the future.get
(String src, SftpProgressMonitor monitor) get
(String src, SftpProgressMonitor monitor, int mode) Deprecated.This method will be deleted in the future.get
(String src, SftpProgressMonitor monitor, long skip) void
get
(String src, OutputStream dst) void
get
(String src, OutputStream dst, SftpProgressMonitor monitor) void
get
(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip) void
void
get
(String src, String dst, SftpProgressMonitor monitor) void
get
(String src, String dst, SftpProgressMonitor monitor, int mode) int
This method will return the value how many requests may be sent at any one time.getExtension
(String key) getHome()
int
void
void
lpwd()
void
ls
(String path, ChannelSftp.LsEntrySelector selector) List files specified by the remotepath
.void
void
put
(InputStream src, String dst) void
put
(InputStream src, String dst, int mode) void
put
(InputStream src, String dst, SftpProgressMonitor monitor) void
put
(InputStream src, String dst, SftpProgressMonitor monitor, int mode) Sends data from the input streamsrc
todst
file.put
(String dst, SftpProgressMonitor monitor, int mode) put
(String dst, SftpProgressMonitor monitor, int mode, long offset) Sends data from the output stream todst
file.void
void
void
put
(String src, String dst, SftpProgressMonitor monitor) void
put
(String src, String dst, SftpProgressMonitor monitor, int mode) Sends data fromsrc
file todst
file.pwd()
void
quit()
void
void
void
void
run()
protected void
void
setAgentForwarding
(boolean enable) Enable the agent forwarding.void
setBulkRequests
(int bulk_requests) Specify how many requests may be sent at any one time.void
setEnv
(byte[] name, byte[] value) Set the environment variable.void
Set the environment variable.void
Deprecated.UsesetEnv(String, String)
orsetEnv(byte[], byte[])
instead.void
setFilenameEncoding
(String encoding) Deprecated.void
setFilenameEncoding
(Charset encoding) void
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
void
setTerminalMode
(byte[] terminal_mode) Set the terminal mode.void
setXForwarding
(boolean enable) Enable the X11 forwarding.void
start()
void
version()
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, setOutputStream
-
Field Details
-
SSH_FX_OK
public static final int SSH_FX_OK- See Also:
-
SSH_FX_EOF
public static final int SSH_FX_EOF- See Also:
-
SSH_FX_NO_SUCH_FILE
public static final int SSH_FX_NO_SUCH_FILE- See Also:
-
SSH_FX_PERMISSION_DENIED
public static final int SSH_FX_PERMISSION_DENIED- See Also:
-
SSH_FX_FAILURE
public static final int SSH_FX_FAILURE- See Also:
-
SSH_FX_BAD_MESSAGE
public static final int SSH_FX_BAD_MESSAGE- See Also:
-
SSH_FX_NO_CONNECTION
public static final int SSH_FX_NO_CONNECTION- See Also:
-
SSH_FX_CONNECTION_LOST
public static final int SSH_FX_CONNECTION_LOST- See Also:
-
SSH_FX_OP_UNSUPPORTED
public static final int SSH_FX_OP_UNSUPPORTED- See Also:
-
OVERWRITE
public static final int OVERWRITE- See Also:
-
RESUME
public static final int RESUME- See Also:
-
APPEND
public static final int APPEND- See Also:
-
agent_forwarding
protected boolean agent_forwarding -
xforwading
protected boolean xforwading -
env
-
pty
protected boolean pty -
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:
start
in classChannel
- Throws:
JSchException
-
quit
public void quit() -
exit
public void exit() -
lcd
- Throws:
SftpException
-
cd
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
Sends data fromsrc
file todst
file. Themode
should beOVERWRITE
,RESUME
orAPPEND
.- Parameters:
src
- source filedst
- destination filemonitor
- progress monitormode
- how data should be added to dst- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
public void put(InputStream src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException Sends data from the input streamsrc
todst
file. Themode
should beOVERWRITE
,RESUME
orAPPEND
.- Parameters:
src
- input streamdst
- destination filemonitor
- progress monitormode
- how data should be added to dst- Throws:
SftpException
-
_put
public void _put(InputStream src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException - Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
- Throws:
SftpException
-
put
public OutputStream put(String dst, SftpProgressMonitor monitor, int mode, long offset) throws SftpException Sends data from the output stream todst
file. Themode
should beOVERWRITE
,RESUME
orAPPEND
.- 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
- Throws:
SftpException
-
get
- Throws:
SftpException
-
get
- Throws:
SftpException
-
get
- Throws:
SftpException
-
get
public void get(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip) throws SftpException - Throws:
SftpException
-
get
- Throws:
SftpException
-
get
- Throws:
SftpException
-
get
Deprecated.This method will be deleted in the future.- Throws:
SftpException
-
get
@Deprecated public InputStream get(String src, SftpProgressMonitor monitor, int mode) throws SftpException Deprecated.This method will be deleted in the future.- Throws:
SftpException
-
get
- 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:
-
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
-
version
-
getHome
- Throws:
SftpException
-
disconnect
public void disconnect()- Overrides:
disconnect
in classChannel
-
getServerVersion
- Throws:
SftpException
-
setFilenameEncoding
Deprecated.- Throws:
SftpException
-
setFilenameEncoding
- Throws:
SftpException
-
getExtension
-
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:
setXForwarding
in classChannel
- Parameters:
enable
-
-
setEnv
Deprecated.UsesetEnv(String, String)
orsetEnv(byte[], byte[])
instead.- See Also:
-
setEnv
Set the environment variable. Ifname
andvalue
are 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:
-
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
Set the terminal type. This method is not effective after Channel#connect().- Parameters:
ttype
- terminal type(for example, "vt100")- See Also:
-
setPtyType
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
- Throws:
Exception
-
run
public void run()
-