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, wait
append, 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, write
protected 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()
IFtpInstance
replyCode
in interface IFtpInstance
public String replyMsg()
IFtpInstance
replyMsg
in interface IFtpInstance
public boolean reply()
IFtpInstance
reply
in interface IFtpInstance
public long transfer(String path, String file, long skip, int size) throws IOException
IFtpInstance
文件不存在则报错
transfer
in interface IFtpInstance
path
- 文件绝对路径file
- 输出流skip
- 跳过字数size
- 读取长度 -1 读取全部IOException
- IOExceptionpublic long transfer(String path, OutputStream out, long skip, int size) throws IOException
IFtpInstance
文件不存在则报错
transfer
in interface IFtpInstance
path
- 文件绝对路径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 IFtpInstance
path
- 文件in
- inIOException
- IOExceptionpublic void write(String path, byte[] bs, int off, int len) throws IOException
IFtpInstance
文件不存在则自动创建
write
in interface IFtpInstance
path
- 文件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 IFtpInstance
path
- 文件in
- inIOException
- IOExceptionpublic void append(String path, byte[] bs, int off, int len) throws IOException
IFtpInstance
文件不存在则自动创建
append
in interface IFtpInstance
path
- 文件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 IFtpInstance
remoteFile
- 远程文件localFile
- 本地文件IOException
- IOExceptionpublic void downloadFile(String remoteFile, String localFile) throws IOException
IFtpInstance
downloadFile
in interface IFtpInstance
remoteFile
- 远程文件路径localFile
- 本地文件IOException
- pendingpublic List<FtpFile> listFiles(String path, boolean child, boolean dir)
IFtpInstance
listFiles
in interface IFtpInstance
path
- 路径child
- 是否遍历子目录dir
- 是否添加文件夹public List<FtpFile> listDirs(String path, boolean child)
IFtpInstance
listDirs
in interface IFtpInstance
path
- 路径child
- 是否遍历public boolean pending() throws IOException
IFtpInstance
pending
in interface IFtpInstance
IOException
- IOExceptionpublic void restartOffset(long offset)
IFtpInstance
restartOffset
in interface IFtpInstance
offset
- offsetpublic void reset()
IFtpInstance
reset
in interface IFtpInstance
public String getSystemType()
IFtpInstance
getSystemType
in interface IFtpInstance
public String getStatus()
IFtpInstance
getStatus
in interface IFtpInstance
public String getStatus(String path)
IFtpInstance
getStatus
in interface IFtpInstance
path
- 文件夹public org.apache.commons.net.ftp.FTPClient getClient()
IFtpInstance
getClient
in interface IFtpInstance
public FtpConfig getConfig()
IFtpInstance
getConfig
in interface IFtpInstance
public FtpClientPool getPool()
IFtpInstance
getPool
in interface IFtpInstance
public boolean sendNoop() throws IOException
IFtpInstance
sendNoop
in interface IFtpInstance
IOException
- IOExceptionpublic String serverCharset(String chars)
IFtpInstance
serverCharset
in interface IFtpInstance
chars
- charspublic String localCharset(String chars)
IFtpInstance
localCharset
in interface IFtpInstance
chars
- charspublic void destroy()
Destroyable
destroy
in interface Destroyable
public void close()
SafeCloseable
close
in interface SafeCloseable
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2024. All rights reserved.