public class FTPUtil extends Object
| 构造器和说明 |
|---|
FTPUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
closeFTPClient(org.apache.commons.net.ftp.FTPClient ftpClient)
关闭ftpClient链接
|
static boolean |
deleteFile(org.apache.commons.net.ftp.FTPClient ftpClient,
String filepath)
删除文件
|
static org.apache.commons.net.ftp.FTPClient |
getFTPClient(String server,
String username,
String password)
获取ftp链接
|
static boolean |
putFile(org.apache.commons.net.ftp.FTPClient ftpClient,
File f,
String uploadDir)
上传文件
|
static boolean |
uploadFile(org.apache.commons.net.ftp.FTPClient ftpClient,
String uploadDir,
String fileName,
InputStream instream)
上传文件lxl
参数:
|
public static org.apache.commons.net.ftp.FTPClient getFTPClient(String server, String username, String password) throws IOException
server - 服务地址username - 用户名password - 密码IOException - 抛出异常public static void closeFTPClient(org.apache.commons.net.ftp.FTPClient ftpClient)
ftpClient - 要关闭的ftpClient对象public static boolean putFile(org.apache.commons.net.ftp.FTPClient ftpClient,
File f,
String uploadDir)
throws IOException
ftpClient - ftp客户端f - 要上传的文件uploadDir - 上传文件的根路径IOException - 抛出异常public static boolean deleteFile(org.apache.commons.net.ftp.FTPClient ftpClient,
String filepath)
throws IOException
ftpClient - ftp客户端filepath - filepath是带有上传目录的path, 后台系统上传的文件, 在数据库中已经存有上传目录, 所以就不用再加.IOException - 抛出异常public static boolean uploadFile(org.apache.commons.net.ftp.FTPClient ftpClient,
String uploadDir,
String fileName,
InputStream instream)
throws IOException
ftpClient - 已获得连接的ftpClientuploadDir - ftp服务器保存目录,如果是根目录则为/fileName - 上传到ftp服务器上的文件名instream - 本地文件输入流IOException - 抛出异常Copyright © 2018 Pivotal Software, Inc.. All rights reserved.