public class SFTPConnector extends java.lang.Object implements Connector
Modifier and Type | Field and Description |
---|---|
static int |
ACTION_CWD |
static int |
ACTION_DEL |
static int |
ACTION_GET |
static int |
ACTION_LIST |
static int |
ACTION_MKD |
static int |
ACTION_PUT |
static int |
ACTION_PWD |
static int |
ACTION_RMD |
static int |
ACTION_SIZE |
static int |
ACTION_TIME |
static int |
FTP_ALL |
static int |
FTP_DIRECTORY |
static int |
FTP_FILE |
static int |
FTP_LINK |
static int |
FTP_UNKNOWN |
protected java.lang.String |
uri |
Constructor and Description |
---|
SFTPConnector(java.util.Map props)
Creates new SFTPConnector
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
connect() |
java.lang.String |
createDirectory(java.lang.String dirname,
int retry)
It checks the existence of the directory tree on the server and creates
the missing ones if necessary.
|
com.jcraft.jsch.ChannelSftp |
getChannelSftp() |
protected static java.lang.String |
getParent(java.lang.String filename)
It returns dirname of the filename or null if it is a relative path.
|
long |
getSize(java.lang.String remote)
returns the file size or -1 in case of failure
|
long |
getTimestamp(java.lang.String remote)
returns the mtime in millis or -1 in case of failure
|
java.lang.String |
getURI() |
boolean |
isConnected() |
static void |
main(java.lang.String[] args) |
java.lang.String |
reconnect()
It reconnects and returns null or error message upon failure
|
java.io.InputStream |
retrieveFileStream(java.lang.String remote) |
boolean |
sftpCwd(java.lang.String pathname) |
boolean |
sftpDelete(java.lang.String pathname) |
java.lang.String |
sftpGet(java.io.File localFile,
java.lang.String filename) |
java.lang.String |
sftpGet(java.io.OutputStream out,
java.lang.String filename) |
java.lang.String |
sftpGet(java.lang.StringBuffer strBuf,
java.lang.String filename) |
java.lang.String[] |
sftpList(java.lang.String dirname,
int type)
It returns an array of strings for requested files of type.
|
boolean |
sftpMkd(java.lang.String pathname) |
java.lang.String |
sftpPut(java.io.File localFile,
java.lang.String filename) |
java.lang.String |
sftpPut(java.io.InputStream in,
java.lang.String filename) |
java.lang.String |
sftpPut(java.lang.String payload,
java.lang.String filename) |
java.lang.String |
sftpPwd() |
boolean |
sftpRmd(java.lang.String pathname) |
java.io.OutputStream |
storeFileStream(java.lang.String remote) |
protected java.lang.String uri
public static final int FTP_ALL
public static final int FTP_FILE
public static final int FTP_DIRECTORY
public static final int FTP_LINK
public static final int FTP_UNKNOWN
public static final int ACTION_PWD
public static final int ACTION_CWD
public static final int ACTION_MKD
public static final int ACTION_RMD
public static final int ACTION_LIST
public static final int ACTION_GET
public static final int ACTION_PUT
public static final int ACTION_DEL
public static final int ACTION_SIZE
public static final int ACTION_TIME
public SFTPConnector(java.util.Map props) throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchException
protected void connect() throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchException
public boolean isConnected()
isConnected
in interface Connector
public java.lang.String reconnect()
public java.lang.String sftpGet(java.io.File localFile, java.lang.String filename)
public java.lang.String sftpGet(java.lang.StringBuffer strBuf, java.lang.String filename)
public java.lang.String sftpGet(java.io.OutputStream out, java.lang.String filename)
public java.lang.String sftpPut(java.io.File localFile, java.lang.String filename)
public java.lang.String sftpPut(java.lang.String payload, java.lang.String filename)
public java.lang.String sftpPut(java.io.InputStream in, java.lang.String filename)
public java.lang.String[] sftpList(java.lang.String dirname, int type) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
public java.lang.String createDirectory(java.lang.String dirname, int retry) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
protected static java.lang.String getParent(java.lang.String filename)
public com.jcraft.jsch.ChannelSftp getChannelSftp()
public java.io.InputStream retrieveFileStream(java.lang.String remote) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
public java.io.OutputStream storeFileStream(java.lang.String remote) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
public boolean sftpDelete(java.lang.String pathname) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
public java.lang.String sftpPwd() throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
public boolean sftpCwd(java.lang.String pathname) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
public boolean sftpMkd(java.lang.String pathname) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
public boolean sftpRmd(java.lang.String pathname) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
public long getSize(java.lang.String remote) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
public long getTimestamp(java.lang.String remote) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpException
public static void main(java.lang.String[] args)