public class SftpClient extends Object
┌─┐ ┌─┐
┌──┘ ┴───────┘ ┴──┐
│ │
│ ─── │
│ ─┬┘ └┬─ │
│ │
│ ─┴─ │
│ │
└───┐ ┌───┘
│ │
│ │
│ │
│ └──────────────┐
│ │
│ ├─┐
│ author:lelouch ┌─┘
│ │
└─┐ ┐ ┌───────┬──┐ ┌──┘
│ ─┤ ─┤ │ ─┤ ─┤
└──┴──┘ └──┴──┘
神兽保佑
代码无BUG!
| 构造器和说明 |
|---|
SftpClient(String hostName,
int port,
String userName,
File privateKey,
String passphrase) |
SftpClient(String hostName,
int port,
String userName,
String password) |
| 限定符和类型 | 方法和说明 |
|---|---|
static List<String> |
buildFiles(Vector ls)
获取目录name
|
com.jcraft.jsch.ChannelSftp |
connect()
连接sftp服务器
|
static com.jcraft.jsch.ChannelSftp |
connect(String host,
int port,
String username,
String password)
连接sftp服务器
|
static void |
delete(String directory,
String deleteFile,
com.jcraft.jsch.ChannelSftp sftp)
删除文件
|
void |
disconnect() |
static InputStream |
download(String directory,
String downloadFile,
com.jcraft.jsch.ChannelSftp sftp)
下载文件
|
static Vector |
listFiles(String directory,
com.jcraft.jsch.ChannelSftp sftp)
列出目录下的文件
|
static void |
mkDir(String dirName,
com.jcraft.jsch.ChannelSftp sftp)
创建指定文件夹
|
static boolean |
openDir(String directory,
com.jcraft.jsch.ChannelSftp sftp)
打开指定目录
|
static void |
upload(String directory,
String uploadFile,
com.jcraft.jsch.ChannelSftp sftp)
上传文件
|
public SftpClient(String hostName, int port, String userName, String password)
hostName - port - userName - password - public com.jcraft.jsch.ChannelSftp connect()
throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchExceptionpublic void disconnect()
public static com.jcraft.jsch.ChannelSftp connect(String host, int port, String username, String password)
host - 主机port - 端口username - 用户名password - 密码public static void upload(String directory, String uploadFile, com.jcraft.jsch.ChannelSftp sftp)
directory - 上传的目录uploadFile - 要上传的文件sftp - public static InputStream download(String directory, String downloadFile, com.jcraft.jsch.ChannelSftp sftp)
directory - 下载目录downloadFile - 下载的文件sftp - public static void delete(String directory, String deleteFile, com.jcraft.jsch.ChannelSftp sftp)
directory - 要删除文件所在目录deleteFile - 要删除的文件sftp - public static Vector listFiles(String directory, com.jcraft.jsch.ChannelSftp sftp) throws com.jcraft.jsch.SftpException
directory - 要列出的目录sftp - com.jcraft.jsch.SftpExceptionpublic static List<String> buildFiles(Vector ls) throws Exception
Vector - 目录集合com.jcraft.jsch.SftpExceptionExceptionpublic static boolean openDir(String directory, com.jcraft.jsch.ChannelSftp sftp)
directory - directorypublic static void mkDir(String dirName, com.jcraft.jsch.ChannelSftp sftp)
dirName - dirNameCopyright © 2020. All rights reserved.