public class FTPUtils extends Object
获取client
上传文件
下载文件
删除文件
| 构造器和说明 |
|---|
FTPUtils(String configPath)
已过时。
|
FTPUtils(String _username,
String _password,
String _url)
构造函数,获取连接
|
FTPUtils(String _username,
String _password,
String _url,
Integer _port)
构造函数,获取连接
|
FTPUtils(String _username,
String _password,
String _url,
Integer _port,
String _enconding)
构造函数,获取连接
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
changeDiretory(String path)
改变当前路径,多级目录使用/分隔,如果目录不存在则新建目录
|
void |
close()
关闭ftp连接
|
Boolean |
downloadFile(String fileName,
String remotePath,
File LocalFile)
下载文件
|
org.apache.commons.net.ftp.FTPClient |
getClient() |
Boolean |
uploadFile(File srcFile,
String remotePath)
上传文件至服务器
|
Boolean |
uploadFile(File srcFile,
String newFileName,
String remotePath)
上传文件至服务器
|
Boolean |
uploadFiles(List<File> files,
List<String> fileNames,
String remotePath)
批量上传文件
|
Boolean |
uploadFiles(List<File> files,
String remotePath)
批量上传文件,文件名不变
|
public FTPUtils(String _username, String _password, String _url)
_username - _password - _url - public FTPUtils(String _username, String _password, String _url, Integer _port)
_username - _password - _url - _port - public FTPUtils(String _username, String _password, String _url, Integer _port, String _enconding)
_username - _password - _url - _port - _enconding - @Deprecated public FTPUtils(String configPath)
configPath - public Boolean uploadFile(File srcFile, String remotePath)
srcFile - 源文件remotePath - 服务器路径public Boolean uploadFile(File srcFile, String newFileName, String remotePath)
srcFile - 源文件newFileName - 上传后文件名remotePath - 服务器路径public Boolean uploadFiles(List<File> files, List<String> fileNames, String remotePath)
files - 源文件fileNames - 上传后文件名remotePath - 服务器路径public Boolean uploadFiles(List<File> files, String remotePath)
files - 源文件remotePath - 服务器路径public Boolean downloadFile(String fileName, String remotePath, File LocalFile)
fileName - 服务器文件名remotePath - 服务器路径LocalFile - 下载至本地文件public void close()
public void changeDiretory(String path) throws IOException
path - IOExceptionpublic org.apache.commons.net.ftp.FTPClient getClient()
Copyright © 2017. All rights reserved.