public abstract class FileDownload extends Object
┌─┐ ┌─┐
┌──┘ ┴───────┘ ┴──┐
│ │
│ ─── │
│ ─┬┘ └┬─ │
│ │
│ ─┴─ │
│ │
└───┐ ┌───┘
│ │
│ │
│ │
│ └──────────────┐
│ │
│ ├─┐
│ author:lelouch ┌─┘
│ │
└─┐ ┐ ┌───────┬──┐ ┌──┘
│ ─┤ ─┤ │ ─┤ ─┤
└──┴──┘ └──┴──┘
神兽保佑
代码无BUG!
| 限定符和类型 | 字段和说明 |
|---|---|
protected long |
connLength |
static ExecutorService |
ctpool |
protected String |
filename |
protected String |
id |
protected double |
limitSpeed
限速标志(单位:Kb/s)
|
protected long |
timeEnd |
protected long |
timeStart |
protected String |
tmpformat |
protected URL |
url |
protected int |
velocityInterval |
| 构造器和说明 |
|---|
FileDownload(ExecutorService tpool,
String savePath,
URL url)
e.g: ExecutorService tpool = Executors.newFixedThreadPool(5); |
FileDownload(ExecutorService tpool,
String savePath,
URL url,
double limitSpeed)
e.g: ExecutorService tpool = Executors.newFixedThreadPool(5); |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
onDownload(int speed,
long byteSum,
long connLength) |
protected void |
onEnd(long timeEnd,
String fileName) |
protected void |
onError(Exception e,
String url) |
protected void |
onLock(Exception e,
String url) |
protected void |
onStart(long timeStart,
long connLength,
String tempName) |
void |
run() |
void |
setVelocityInterval(int velocityInterval)
设置输出间隔 毫秒
|
public static ExecutorService ctpool
protected double limitSpeed
protected int velocityInterval
protected long connLength
protected URL url
protected String filename
protected String tmpformat
protected long timeStart
protected long timeEnd
protected String id
public FileDownload(ExecutorService tpool, String savePath, URL url, double limitSpeed)
tpool - 设置线程池savePath - 保存路径url - 文件地址limitSpeed - 限速public FileDownload(ExecutorService tpool, String savePath, URL url)
tpool - 设置线程池savePath - 保存路径url - 文件地址public void setVelocityInterval(int velocityInterval)
public void run()
protected void onDownload(int speed,
long byteSum,
long connLength)
speed - 速度byteSum - 已下载大小connLength - 文件大小protected void onStart(long timeStart,
long connLength,
String tempName)
timeStart - 开始时间connLength - 文件大小tempName - 缓存文件protected void onEnd(long timeEnd,
String fileName)
timeEnd - 结束时间fileName - 文件名Copyright © 2020. All rights reserved.