如何用Java实现HTTP断点续传功能
2个回答
展开全部
我项目中用到的关键代码,断点下载文件:
URL url = new URL("http://f1.market.xiaomi.com/download/AppStore/0279e54e42c95454b29ac9628eccb1bfb5be22aeb/dian.zi.com.zidian.apk");
HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
httpConnection.setRequestProperty("User-Agent", "NetFox");
httpConnection.setReadTimeout(60000);
//xxx表示你已下载的文件大小
httpConnection.setRequestProperty("RANGE", "bytes=" + xxx + "-");
URL url = new URL("http://f1.market.xiaomi.com/download/AppStore/0279e54e42c95454b29ac9628eccb1bfb5be22aeb/dian.zi.com.zidian.apk");
HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
httpConnection.setRequestProperty("User-Agent", "NetFox");
httpConnection.setReadTimeout(60000);
//xxx表示你已下载的文件大小
httpConnection.setRequestProperty("RANGE", "bytes=" + xxx + "-");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询