public class SFTPUtil extends Object
| 构造器和说明 |
|---|
SFTPUtil() |
SFTPUtil(String host,
int port,
String user,
String password) |
SFTPUtil(String host,
String user,
String password) |
SFTPUtil(String host,
String user,
String password,
int port) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
deleteDir(String path)
删除文件夹-sftp协议.如果文件夹有内容,则会抛出异常.
|
void |
deleteFile(String path)
删除文件-sftp协议.
|
boolean |
dirExist(String dir)
判断文件夹是否存在.
|
boolean |
disconnect()
断开连接
|
void |
download(String remote,
String local)
下载文件-sftp协议.
|
boolean |
fileExists(String path) |
boolean |
fileExists(String dir,
String file) |
List<String> |
files(String dir) |
int |
fileSize(String remoteDir) |
static SFTPUtil |
getInstance(String host,
String account,
String password) |
static SFTPUtil |
getInstance(String host,
String account,
String password,
int port) |
boolean |
mkdir(String dir)
根据路径创建文件夹.
|
boolean |
mkdirs(String dir)
递归创建文件夹.
|
void |
uploadFile(File localFile,
String remoteDir,
String remoteFile) |
boolean |
uploadFile(String localFile)
上传文件-sftp协议.
|
void |
uploadFile(String localFile,
String remoteDir,
String remoteFile)
上传文件-sftp协议.
|
public SFTPUtil(String host, int port, String user, String password) throws Exception
Exceptionpublic static SFTPUtil getInstance(String host, String account, String password, int port)
public void download(String remote, String local) throws Exception
remote - 下载的文件local - 存在本地的路径Exception - 异常public boolean disconnect()
public int fileSize(String remoteDir)
public void deleteFile(String path) throws com.jcraft.jsch.SftpException
path - 要删除的文件com.jcraft.jsch.SftpException - 异常public void deleteDir(String path) throws com.jcraft.jsch.SftpException
path - 文件夹路径com.jcraft.jsch.SftpException - SftpExceptionpublic void uploadFile(String localFile, String remoteDir, String remoteFile) throws com.jcraft.jsch.SftpException
localFile - 源文件remoteDir - 远程保存路径remoteFile - 远程保存文件名com.jcraft.jsch.SftpException - 异常public void uploadFile(File localFile, String remoteDir, String remoteFile) throws com.jcraft.jsch.SftpException
com.jcraft.jsch.SftpExceptionpublic boolean uploadFile(String localFile) throws com.jcraft.jsch.SftpException
localFile - 源文件路径,/xxx/xx.yy 或 x:/xxx/xxx.yycom.jcraft.jsch.SftpException - 异常public boolean mkdir(String dir) throws com.jcraft.jsch.SftpException
dir - 路径 必须是 /xxx/xxx/ 不能就单独一个/com.jcraft.jsch.SftpException - 异常public boolean mkdirs(String dir) throws com.jcraft.jsch.SftpException
dir - 路径com.jcraft.jsch.SftpException - 异常public boolean dirExist(String dir)
dir - 文件夹路径, /xxx/xxx/public boolean fileExists(String path)
Copyright © 2022. All rights reserved.