程序包 org.anyline.net
类 FTPUtil
java.lang.Object
org.anyline.net.FTPUtil
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明booleanbooleanvoidconnect()voiddeleteFile(String ftpFileName) Delete the file from the FTP server.voidbooleandownloadDir(String remoteDir, File localDir) 下载整个目录booleandownloadFile(String remote, File local) 下载单个文件intformatPath(String srcPath) 格式化路径.getDir()org.apache.commons.net.ftp.FTPClientstatic FTPUtilgetInstance(String host, String account, String password) static FTPUtilgetInstance(String host, String account, String password, int port) Get parent directory name on ftp serverbooleanTest connection to ftp serverboolean创建目录boolean修改名称voidretrieveFile(String ftpFileName, OutputStream out) Get file from ftp server into given output streamvoidsendSiteCommand(String args) voidsetControlEncoding(String charset) voidsetFileType(int fileType) voidsetTimeOut(int defaultTimeoutSecond, int connectTimeoutSecond, int dataTimeoutSecond) voidstoreFile(String ftpFileName, InputStream in) Put file on ftp server from given input streambooleanvoid上传目录(会覆盖)booleanuploadFile(File local, String remote) booleanuploadFile(String remote, File local)
-
构造器详细资料
-
FTPUtil
public FTPUtil() -
FTPUtil
-
FTPUtil
-
-
方法详细资料
-
getInstance
-
getInstance
-
setTimeOut
public void setTimeOut(int defaultTimeoutSecond, int connectTimeoutSecond, int dataTimeoutSecond) -
fileSize
-
downloadFile
下载单个文件- 参数:
remote- remotelocal- local- 返回:
- boolean
-
getFTPClient
public org.apache.commons.net.ftp.FTPClient getFTPClient() -
setControlEncoding
-
setFileType
- 抛出:
IOException
-
connect
public void connect() -
isConnected
public boolean isConnected()Test connection to ftp server- 返回:
- true, if connected
-
disconnect
public void disconnect() -
retrieveFile
Get file from ftp server into given output stream- 参数:
ftpFileName- file name on ftp serverout- OutputStream- 抛出:
IOException- IOException
-
storeFile
Put file on ftp server from given input stream- 参数:
ftpFileName- file name on ftp serverin- InputStream- 抛出:
IOException- IOException
-
rename
修改名称- 参数:
from- fromto- to- 返回:
- boolean
- 抛出:
IOException- IOException
-
deleteFile
Delete the file from the FTP server.- 参数:
ftpFileName- server file name (with absolute path)- 抛出:
IOException- on I/O errors
-
uploadFile
-
uploadFile
-
upload
-
uploadDir
上传目录(会覆盖)- 参数:
remotePath- 远程目录 /home/test/alocal- 本地目录 D:/test/a
-
downloadDir
下载整个目录- 参数:
remoteDir- remoteDirlocalDir- localDir- 返回:
- boolean
-
cd
-
files
- 抛出:
IOException
-
sendSiteCommand
- 抛出:
IOException
-
printWorkingDirectory
-
changeToParentDirectory
public boolean changeToParentDirectory() -
getParentDirectory
Get parent directory name on ftp server- 返回:
- parent directory
-
makeDir
创建目录- 参数:
path- path- 返回:
- boolean
- 抛出:
IOException- IOException
-
formatPath
格式化路径.- 参数:
srcPath- 原路径. /xxx/xxx/xxx.yyy 或 X:/xxx/xxx/xxx.yy- 返回:
- list, 第一个是路径(/xxx/xxx/), 第二个是文件名(xxx.yy)
-
getDir
-