public abstract class BaseFtpInstance extends Object implements IFtpInstance
| Modifier and Type | Field and Description |
|---|---|
protected int |
bufferSize |
protected org.apache.commons.net.ftp.FTPClient |
client
FTP 连接
|
protected FtpConfig |
config
FTP 配置
|
protected FtpClientPool |
pool
FTP 连接池
|
protected static String |
SEPARATOR
分隔符
|
| Constructor and Description |
|---|
BaseFtpInstance(org.apache.commons.net.ftp.FTPClient client,
FtpConfig config) |
BaseFtpInstance(FtpClientPool pool) |
| Modifier and Type | Method and Description |
|---|---|
void |
append(String path,
byte[] bs,
int off,
int len)
拼接字节数组到文件
文件不存在则自动创建
|
void |
append(String path,
InputStream in)
拼接流到文件
文件不存在则自动创建
|
void |
close()
安全关闭
|
void |
destroy()
销毁
|
protected abstract void |
doAppend(String path,
InputStream in,
StreamEntry entry)
执行拼接
|
protected abstract long |
doTransfer(String path,
OutputStream out,
long skip,
int size,
boolean close)
执行传输
|
void |
downloadFile(String remoteFile,
String localFile)
下载文件
|
protected abstract void |
doWrite(String path,
InputStream in,
StreamEntry entry)
执行写入
|
org.apache.commons.net.ftp.FTPClient |
getClient()
获取连接
|
FtpConfig |
getConfig()
获取配置
|
FtpClientPool |
getPool()
获取连接池
|
String |
getStatus()
获取文件夹状态
|
String |
getStatus(String path)
获取文件夹状态 会获取文件列表
|
String |
getSystemType()
获取系统类型
|
List<FtpFile> |
listDirs(String path,
boolean child)
列出文件夹
|
List<FtpFile> |
listFiles(String path,
boolean child,
boolean dir)
文件和文件夹列表
|
String |
localCharset(String chars)
本地编码
|
boolean |
pending()
等待处理命令完毕 事务
|
boolean |
reply()
获取上一次命令的reply
|
int |
replyCode()
获取上一次命令的 replyCode
|
String |
replyMsg()
获取上一次命令的 replyCode 对应的 message
|
void |
reset()
重置 io
|
void |
restartOffset(long offset)
设置偏移量
|
boolean |
sendNoop()
发送心跳
|
String |
serverCharset(String chars)
ftp 服务文件编码
|
long |
transfer(String path,
OutputStream out,
long skip,
int size)
读取字节到输出流
文件不存在则报错
|
long |
transfer(String path,
String file,
long skip,
int size)
读取字节到文件
文件不存在则报错
|
void |
uploadFile(String remoteFile,
String localFile)
上传文件
远程文件存在则会覆盖
远程文件是个文件夹则会报错
|
void |
write(String path,
byte[] bs,
int off,
int len)
写入字节数组到文件
文件不存在则自动创建
|
void |
write(String path,
InputStream in)
写入流到文件
文件不存在则自动创建
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitappend, append, change, change, download, download, downloadDir, downloadDir, downloadDir, downloadDir, downloadFile, downloadFile, downloadFile, getFile, getModifyTime, getSize, getWorkDirectory, isExist, listDirs, listFiles, listFiles, listFilesFilter, listFilesFilter, listFilesFilter, makeDirectories, move, openInputStream, openInputStream, openOutputStream, openOutputStream, read, read, read, read, remove, removeDir, removeFile, setModifyTime, touch, transfer, transfer, transfer, transfer, transfer, transfer, truncate, upload, upload, uploadDir, uploadDir, uploadDir, uploadDir, uploadFile, uploadFile, uploadFile, write, writeprotected static final String SEPARATOR
protected org.apache.commons.net.ftp.FTPClient client
protected FtpConfig config
protected FtpClientPool pool
protected int bufferSize
public BaseFtpInstance(FtpClientPool pool)
public BaseFtpInstance(org.apache.commons.net.ftp.FTPClient client,
FtpConfig config)
public int replyCode()
IFtpInstancereplyCode in interface IFtpInstancepublic String replyMsg()
IFtpInstancereplyMsg in interface IFtpInstancepublic boolean reply()
IFtpInstancereply in interface IFtpInstancepublic long transfer(String path, String file, long skip, int size) throws IOException
IFtpInstance文件不存在则报错
transfer in interface IFtpInstancepath - 文件绝对路径file - 输出流skip - 跳过字数size - 读取长度 -1 读取全部IOException - IOExceptionpublic long transfer(String path, OutputStream out, long skip, int size) throws IOException
IFtpInstance文件不存在则报错
transfer in interface IFtpInstancepath - 文件绝对路径out - 输出流skip - 跳过字数size - 读取长度 -1 读取全部IOException - IOExceptionprotected abstract long doTransfer(String path, OutputStream out, long skip, int size, boolean close) throws IOException
path - pathout - outskip - skipsize - sizeclose - closeIOException - IOExceptionpublic void write(String path, InputStream in) throws IOException
IFtpInstance文件不存在则自动创建
write in interface IFtpInstancepath - 文件in - inIOException - IOExceptionpublic void write(String path, byte[] bs, int off, int len) throws IOException
IFtpInstance文件不存在则自动创建
write in interface IFtpInstancepath - 文件bs - 字节数组off - 偏移量len - 长度IOException - IOExceptionprotected abstract void doWrite(String path, InputStream in, StreamEntry entry) throws IOException
path - pathin - inentry - entryIOException - IOExceptionpublic void append(String path, InputStream in) throws IOException
IFtpInstance文件不存在则自动创建
append in interface IFtpInstancepath - 文件in - inIOException - IOExceptionpublic void append(String path, byte[] bs, int off, int len) throws IOException
IFtpInstance文件不存在则自动创建
append in interface IFtpInstancepath - 文件bs - 字节数组off - 偏移量len - 长度IOException - IOExceptionprotected abstract void doAppend(String path, InputStream in, StreamEntry entry) throws IOException
path - pathin - inentry - entryIOException - IOExceptionpublic void uploadFile(String remoteFile, String localFile) throws IOException
IFtpInstance远程文件存在则会覆盖
远程文件是个文件夹则会报错
uploadFile in interface IFtpInstanceremoteFile - 远程文件localFile - 本地文件IOException - IOExceptionpublic void downloadFile(String remoteFile, String localFile) throws IOException
IFtpInstancedownloadFile in interface IFtpInstanceremoteFile - 远程文件路径localFile - 本地文件IOException - pendingpublic List<FtpFile> listFiles(String path, boolean child, boolean dir)
IFtpInstancelistFiles in interface IFtpInstancepath - 路径child - 是否遍历子目录dir - 是否添加文件夹public List<FtpFile> listDirs(String path, boolean child)
IFtpInstancelistDirs in interface IFtpInstancepath - 路径child - 是否遍历public boolean pending()
throws IOException
IFtpInstancepending in interface IFtpInstanceIOException - IOExceptionpublic void restartOffset(long offset)
IFtpInstancerestartOffset in interface IFtpInstanceoffset - offsetpublic void reset()
IFtpInstancereset in interface IFtpInstancepublic String getSystemType()
IFtpInstancegetSystemType in interface IFtpInstancepublic String getStatus()
IFtpInstancegetStatus in interface IFtpInstancepublic String getStatus(String path)
IFtpInstancegetStatus in interface IFtpInstancepath - 文件夹public org.apache.commons.net.ftp.FTPClient getClient()
IFtpInstancegetClient in interface IFtpInstancepublic FtpConfig getConfig()
IFtpInstancegetConfig in interface IFtpInstancepublic FtpClientPool getPool()
IFtpInstancegetPool in interface IFtpInstancepublic boolean sendNoop()
throws IOException
IFtpInstancesendNoop in interface IFtpInstanceIOException - IOExceptionpublic String serverCharset(String chars)
IFtpInstanceserverCharset in interface IFtpInstancechars - charspublic String localCharset(String chars)
IFtpInstancelocalCharset in interface IFtpInstancechars - charspublic void destroy()
Destroyabledestroy in interface Destroyablepublic void close()
SafeCloseableclose in interface SafeCloseableclose in interface Closeableclose in interface AutoCloseableCopyright © 2025. All rights reserved.