public abstract class BaseFileDownloader extends Object implements IFileDownloader
Modifier and Type | Field and Description |
---|---|
protected int |
bufferSize
缓冲区大小
|
protected boolean |
fileSizeEqualOverride
文件大小相同则覆盖下载
|
protected boolean |
forceOverride
是否强制覆盖下载 (不检测文件锁定/不检测文件大小/不走断点续传)
|
protected File |
local
本地文件
|
protected FileLocks.NamedFileLock |
lock
文件锁
|
protected ByteTransferRateProgress |
progress
进度条
|
protected String |
remote
远程文件
|
protected Long |
remoteFileLength
远程文件大小 缓存
|
Constructor and Description |
---|
BaseFileDownloader(String remote,
File local,
String lockSuffix,
int bufferSize) |
Modifier and Type | Method and Description |
---|---|
protected void |
breakPointResume(long skip)
断点续传
|
boolean |
checkRemoteFilePresentSizeEqual()
检查远程文件存在并且大小相同
|
protected void |
download()
直接下载
|
void |
fileSizeEqualOverride(boolean fileSizeEqualOverride)
文件大小相同则覆盖下载
|
void |
forceOverride(boolean forceOverride)
强制覆盖下载 (不检测文件锁定/不检测文件大小/不走断点续传)
|
ByteTransferRateProgress |
getProgress()
获取传输进度条
|
long |
getRemoteFileLength()
获取远程文件大小
|
protected abstract long |
getRemoteFileSize()
获取远程文件大小
|
protected abstract void |
initDownload(boolean breakPoint,
long skip)
准开始下载
|
protected abstract int |
read(byte[] bs)
读取数据
|
protected void |
startDownload()
开始下载
|
protected abstract void |
transferFinish()
传输完成回调
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
abort
close
protected final String remote
protected final File local
protected final FileLocks.NamedFileLock lock
protected final ByteTransferRateProgress progress
protected int bufferSize
protected boolean forceOverride
protected boolean fileSizeEqualOverride
protected Long remoteFileLength
public void forceOverride(boolean forceOverride)
IFileDownloader
forceOverride
in interface IFileDownloader
forceOverride
- 是否覆盖public void fileSizeEqualOverride(boolean fileSizeEqualOverride)
IFileDownloader
fileSizeEqualOverride
in interface IFileDownloader
fileSizeEqualOverride
- fileSizeEqualOverridepublic long getRemoteFileLength() throws IOException
IFileDownloader
getRemoteFileLength
in interface IFileDownloader
IOException
- IOExceptionpublic boolean checkRemoteFilePresentSizeEqual() throws IOException
IFileDownloader
checkRemoteFilePresentSizeEqual
in interface IFileDownloader
IOException
- IOExceptionprotected void startDownload() throws IOException
IOException
- IOExceptionprotected void download() throws IOException
IOException
- IOExceptionprotected void breakPointResume(long skip) throws IOException
skip
- 跳过的长度IOException
- IOExceptionprotected abstract long getRemoteFileSize() throws IOException
IOException
- IOExceptionprotected abstract void initDownload(boolean breakPoint, long skip) throws IOException
breakPoint
- 是否为断点续传skip
- 跳过的长度IOException
- IOExceptionprotected abstract int read(byte[] bs) throws IOException
bs
- bsIOException
- IOExceptionprotected abstract void transferFinish() throws IOException
IOException
- IOExceptionpublic ByteTransferRateProgress getProgress()
IFileTransfer
getProgress
in interface IFileTransfer
Copyright © 2024. All rights reserved.