public class DownloadUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
CONNECT_TIME_OUT
连接超时设置
|
static int |
READ_TIME_OUT
读取数据超时
|
| 构造器和说明 |
|---|
DownloadUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
createFile(String path,
long length)
创建固定大小的文件
|
static void |
download(String url,
String filePath,
BiConsumer<Integer,Integer> progressCallback)
下载
|
static long |
getContentLength(String url)
获取下载得文件长度
|
static ThreadPoolExecutor |
getExecutor()
创建一个用于下载chrome的线程池
|
public static final int READ_TIME_OUT
public static final int CONNECT_TIME_OUT
public static void download(String url, String filePath, BiConsumer<Integer,Integer> progressCallback) throws IOException, ExecutionException, InterruptedException
url - 载的资源定位路径filePath - 文件路径progressCallback - 下载回调IOException - 异常ExecutionException - 异常InterruptedException - 异常public static final long getContentLength(String url) throws IOException
url - 资源定位路径IOException - 连接异常public static ThreadPoolExecutor getExecutor()
public static void createFile(String path, long length) throws IOException
path - 文件路径length - 文件大小IOException - 操作文件异常Copyright © 2020. All rights reserved.