大佬教程收集整理的这篇文章主要介绍了Android:下载大文件,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
private class DownloadTask extends AsyncTask<DatabaseInfo,Integer,String> { private DatabaseInfo info; protected String doInBACkground(DatabaseInfo... dbInfo) { int count; info = dbInfo[0]; try { URL url = new URL(dbInfo[0].dbPath); InputStream input = new BufferedInputStream(url.openStream()); OutputStream output = new FiLeoutputStream("/sdcard/db.zip"); byte data[] = new byte[1024]; int @R_808_1@R_674_11226@6@l = 0; while ((count = input.read(data)) != -1) { //output.write(data,count); @R_808_1@R_674_11226@6@l += count; if (@R_808_1@R_674_11226@6@l % 10240 == 0) { publishProgress(@R_808_1@R_674_11226@6@l); } } output.flush(); output.close(); input.close(); } catch (Exception E) { Log.e("err",e.getmessage()); } return null; } protected void onProgressupdate(Integer... @R_808_1@R_674_11226@6@l) { int perc = (int) ((float) @R_808_1@R_674_11226@6@l[0] / (float) info.dbZipSize * 100); mProgressDialog.setProgress(perc); } protected void onPostExecute(String s) { dismissDialog(DIALOG_PROGRESS); Log.e("err","finish!"); } }
如果我取消注释行
//output.write(data,count);
7-15%下载进度条对话框关闭后,我看到“完成!”在日志中.为什么?
以上是大佬教程为你收集整理的Android:下载大文件全部内容,希望文章能够帮你解决Android:下载大文件所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。