/*
软件作者:https://xuhss.com/oxox/pro
*/
/**
* 作者: 家
* QQ: 203118908
* 功能: 显示下载文件百分比
*/
// importClass("javax.swing.*")
importClass("java.io.FileOutputStream")
importClass("java.io.IOException")
importClass("java.io.InputStream")
importClass("java.net.MalformedURLException")
importClass("java.net.URL")
importClass("java.net.URLConnection")
importClass("java.util.ArrayList")
myPath = "/sdcard/111aa/abc.js";
log('im alive')
var myUrl = 'http://bmob-cdn-11368.b0.upaiyun.com/2019/03/15/e7109b1040cf97db8008992f5fbec664.test'
url = new URL(myUrl);
conn = url.openConnection(); //URLConnection
inStream = conn.getInputStream(); //InputStream
fs = new FileOutputStream(myPath); //FileOutputStream
connLength = conn.getContentLength(); //int
startTime = java.lang.System.currentTimeMillis();
buffer = util.java.array('byte', 1024); //byte[]
// buffer = new byte[1204]; //byte[]
prevTime = java.lang.System.currentTimeMillis();
bytePrev = 0; //前一次记录的文件大小
byteSum = 0; //总共读取的文件大小
var byteRead; //每次读取的byte数
log('要下载的文件大小=')
log(connLength)
threads.start(
function(){
while(1){
var 当前写入的文件大小=byteSum
var 百分比=当前写入的文件大小/connLength*100
var 要显示的内容=util.format('下载了%s%',百分比)
log(要显示的内容)
if(当前写入的文件大小>=connLength){
break;
}
sleep(1000)
}
}
)
while ((byteRead = inStream.read(buffer)) != -1) {
byteSum += byteRead;
//当前时间
currentTime = java.lang.System.currentTimeMillis();
fs.write(buffer, 0, byteRead); //读取
}
没有合适的资源?快使用搜索试试~ 我知道了~
AutoJs源码-下载文件百分比
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共1个文件
js:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
需积分: 5 0 下载量 8 浏览量
2022-11-15
07:47:37
上传
评论
收藏 1KB 7Z 举报
温馨提示
AutoJs源码-下载文件百分比。本资源购买前提醒:本源码都是实际autojs项目模板,安装好autojs直接运行即可打开。1、支持低版本autojs。2、资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!。3、安装过程详见具体资源,不会使用autojs谨慎下载
资源推荐
资源详情
资源评论
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 1 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
[虚幻私塾】
- 粉丝: 335
- 资源: 1558
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- torchvision中CIFAR10数据集
- 山东大学面向对象编程考试内容的详细归纳
- 基于LoRa的主从机农田监测系统代码
- 计算机组成原理第六版课后习题可能涉及的一些主要内容和概念
- Visual Studio 最新版一键安装包(何时安装何时就可以最新版)
- Matplotlib - Matplotlib tutorial - Nicolas P. Rougier
- XlineSoft PHPRunner 是一款功能强大且灵活的 PHP 代码生成器,专为快速开发和部署数据库驱动的 Web 应用
- c语言之俄罗斯方块123
- matplotlib - matplotlib for beginners
- ensp构建一个小型校园网
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)