How does the multi-threaded download of "android face question" be implemented? How do I implement a breakpoint continuation?

Source: Internet
Author: User
<span id="Label3"> </p><style>!--body {font-family:helvetica, arial, sans-serif; font-size:14px; line-height:1.6; padding-top:10px; padding-bottom:10px; background-color:white; padding:30px; }body > *:first-child {margin-top:0!important;} Body > *:last-child {margin-bottom:0!important;} A {color: #4183C4;} A.absent {color: #cc0000;} A.anchor {display:block; padding-left:30px; Margin-left: -30px; cursor:pointer; position:absolute; top:0; left:0; bottom:0; }h1, h2, h3, h4, h5, h6 {margin:20px 0 10px; padding:0; font-weight:bold; -webkit-font-smoothing:antialiased; cursor:text; position:relative; }h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {backg Round:url (data:image/png;base64,ivborw0kggoaaaansuheugaaabaaaaaqcayaaaaf8/ 9haaaagxrfwhrtb2z0d2fyzqbbzg9izsbjbwfnzvjlywr5ccllpaaaa09pvfh0we1momnvbs5hzg9izs54bxaaaaaaadw/ Ehbhy2tldcbizwdpbj0i77u/iibpzd0ivzvnme1wq2voauh6cmvtek5uy3pryzlkij8+idx4onhtcg1ldGegeg1sbnm6ed0iywrvymu6bnm6bwv0ys8iihg6eg1wdgs9ikfkb2jlifhnucbdb3jliduumy1jmdexidy2lje0nty2mswgmjaxmi8wmi8wni0xndo1njoyny Agicagicagij4gphjkzjpsreygeg1sbnm6cmrmpsjodhrwoi8vd3d3lnczlm9yzy8xotk5lzaylziylxjkzi1zew50yxgtbnmjij4gphjkzjpezxnjcmlwdgl Vbibyzgy6ywjvdxq9iiigeg1sbnm6eg1wpsjodhrwoi8vbnmuywrvymuuy29tl3hhcc8xljaviib4bwxuczp4bxbntt0iahr0cdovl25zlmfkb2jllmnvbs94 Yxavms4wl21tlyigeg1sbnm6c3rszwy9imh0dha6ly9ucy5hzg9izs5jb20vegfwlzeumc9zvhlwzs9szxnvdxjjzvjlzimiihhtcdpdcmvhdg9yvg9vbd0iq Wrvymugughvdg9zag9wientniaomtmumcaymdeymdmwns5tljqxnsaymdeylzazlza1ojixojawojawksagke1hy2ludg9zackiihhtce1nokluc3rhbmnlsu Q9inhtcc5pawq6oum2njldqji4odbgmtffmtg1odleodnerdjbrjuwqtqiihhtce1nokrvy3vtzw50suq9inhtcc5kawq6oum2njldqjm4odbgmtffmtg1odl Eodnerdjbrjuwqtqipia8eg1wtu06rgvyaxzlzezyb20gc3rszwy6aw5zdgfuy2vjrd0ieg1wlmlpzdo5qzy2ouncmdg4meyxmuuxodu4ouq4m0remkfgntbb ncigc3rszwy6zg9jdw1lbnrjrd0ieg1wlmrpzdo5qzy2ouncmtg4meyxmuuxodu4ouq4m0remkfgntbbncivpia8l3jkzjpezxnjcmlwdglvbj4gpc9yzgy6u Krgpia8l3g6eg1wbwv0yt4gpd94cgfja2v0igvuzd0icii/psqhxeaaaabfsurbvhjayvz// Z8djycrugmyqabambqiaveqkbqwxi6shqwhiwg70ttbxgaiwwjctggougjif1j8wmraiua34b4q76hubelafjysa0cumiearp8wgikgma54bgqimacamkxji0 Hkjqaaaabjru5erkjggg==) no-repeat 10px center; text-decoration:none; }H1 tt, H1 Code {font-size:inherit;} H2 tt, H2 Code {font-size:inherit;} H3 tt, H3 Code {font-size:inherit;} h4 tt, h4 Code {font-size:inherit;} H5 tt, h5 Code {font-size:inherit;} H6 tt, h6 code {font-size:inherit;} H1 {font-size:28px; color:black; }H2 {font-size:24px; BORDER-BOTTOM:1PX Solid #cccccc; color:black; }h3 {font-size:18px;} H4 {font-size:16px;} H5 {font-size:14px;} H6 {color: #777777; font-size:14px; }p, blockquote, ul, ol, dl, li, table, pre {margin:15px 0;} HR {background:transparent URL (data:image/png;base64, Ivborw0kggoaaaansuheugaaaayaaaaecayaaactbe5daaaagxrfwhrtb2z0d2fyzqbbzg9izsbjbwfnzvjlywr5ccllpaaaayjpvfh0we1momnvbs5hzg9iz S54bxaaaaaaadw/ehbhy2tldcbizwdpbj0i77u/iibpzd0ivzvnme1wq2voauh6cmvtek5uy3pryzlkij8+ Idx4onhtcg1ldgegeg1sbnm6ed0iywrvymu6bnm6bwv0ys8iihg6eg1wdgs9ikfkb2jlifhnucbdb3jliduumc1jmdywidyxljezndc3nywgmjaxmc8wmi8xm I0xnzozmjowmcagicagicagij4gphjkzjpsreygeg1sbnm6cmrmpsjodhrwoi8vd3d3lnczlm9yzy8xotk5lzaylziylxjkzi1zew50yxgtbnmjij4gphjkzj Pezxnjcmlwdglvbibyzgy6ywjvdxq9iiigeg1sbnm6eg1wpsjodhrwoi8vbnmuywrvymuuy29tl3hhcc8xljaviib4bwxuczp4bxbntt0iahr0cdovl25zlmf Kb2jllmnvbs94yxavms4wl21tlyigeg1sbnm6c3rszwy9imh0dha6ly9ucy5hzg9izs5jb20vegfwlzeumc9zvhlwzs9szxnvdxjjzvjlzimiihhtcdpdcmvh dg9yvg9vbd0iqwrvymugughvdg9zag9wientnsbnywnpbnrvc2giihhtce1nokluc3rhbmnlsuq9inhtcc5pawq6oendrjnbn0e2ntzbmtffmei3qjrbodm4n Zjdmjlgndgiihhtce1nokrvy3vtzw50suq9inhtcc5kawq6oendrjnbn0i2ntzbmtffmei3qjrbodm4nzjdmjlgndgipia8eg1wtu06rgvyaxzlzezyb20gc3 rszwy6aw5zdgfuy2vjrd0ieg1wlmlpzdo4q0ngm0e3ody1nkexmuuwqjdcnee4mzg3mkmyouy0ocigc3rszwy6zg9jdw1lbnrjrd0ieg1wlmrpzdo4q0ngm0e 3oty1nkexmuuwqjdcnee4mzg3mkmyouy0ocivpia8l3jkzjpezxnjcmlwdglvbj4gpc9yzgy6ukrgpia8l3g6eg1wbwv0yt4gpd94cgfja2v0igvuzd0icii /pqqezsuaaaafsurbvHJAYMRABCYWBIM2QSA4Y4HNEKYDQXAEAAIMAHNGAZHKPOLYAAAAAELFTKSUQMCC) repeat-x 0 0; border:0 none; Color: #cccccc; height:4px; padding:0;} Body > H2:first-child {margin-top:0; padding-top:0; }body > H1:first-child {margin-top:0; padding-top:0; } Body > H1:first-child + H2 {margin-top:0; padding-top:0; }body > h3:first-child, body > h4:first-child, body > h5:first-child, body > H6:first-child {margin-top:0; padding-top:0; }a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {margin-top: 0; padding-top:0; }H1 p, H2 p, h3 p, h4 p, h5 p, h6 p {margin-top:0;} Li P.first {display:inline-block;} Li {margin:0;} ul, ol {padding-left:30px;} ul:first-child, Ol:first-child {margin-top:0;} DL {padding:0;} DL DT {font-size:14px; font-weight:bold; font-style:italic; padding:0; margin:15px 0 5px; } DL Dt:first-child {padding:0;} DL DT >: First-child {margin-top:0; } DL DT >: last-child {margin-bottom:0;} DL DD {margin:0 0 15px; padding:0 15px; } DL DD >: first-child {margin-top:0;} DL DD >: Last-child {margin-bottom:0;} BLOCKQUOTE {border-left:4px Solid #dddddd; padding:0 15px; Color: #777777; } blockquote >: First-child {margin-top:0;} blockquote >: Last-child {margin-bottom:0;} Table {padding:0;border-collapse:collapse;} Table TR {border-top:1px Solid #cccccc; background-color:white; margin:0; padding:0; } table Tr:nth-child (2n) {background-color: #f8f8f8;} Table TR th {font-weight:bold; BORDER:1PX Solid #cccccc; margin:0; PADDING:6PX 13px; } table TR TD {border:1px Solid #cccccc; margin:0; PADDING:6PX 13px; } Table tr th:first-child, table TR td:first-child {margin-top:0;} Table TR th:last-child, table TR td:last-child {margin-bottom:0;} IMG {max-width:100%;} Span. Frame {display:block; overflow:hidden; } Span.frame > span {border:1px solid #dddddd; display:block; float:left; overflow:hidden; MARGIN:13PX 0 0; padding:7px; width:auto; } span.frame span img {display:block; float:left; } span.frame span span {clear:both; Color: #333333; display:block; padding:5px 0 0; }span.align-center {display:block; overflow:hidden; clear:both; } Span.align-center > span {display:block; overflow:hidden; MARGIN:13PX Auto 0; text-align:center; } span.align-center span img {margin:0 auto; text-align:center; }span.align-right {display:block; overflow:hidden; clear:both; } Span.align-right > span {display:block; overflow:hidden; MARGIN:13PX 0 0; text-align:right; } span.align-right span img {margin:0; text-align:right; }span.float-left {display:block; margin-right:13px; overflow:hidden; float:left; } span.float-left span {mARGIN:13PX 0 0; }span.float-right {display:block; margin-left:13px; overflow:hidden; float:right; } Span.float-right > span {display:block; overflow:hidden; MARGIN:13PX Auto 0; text-align:right; }code, TT {margin:0 2px; padding:0 5px; white-space:nowrap; BORDER:1PX Solid #eaeaea; Background-color: #f8f8f8; border-radius:3px; }pre Code {margin:0; padding:0; white-space:pre; border:none; background:transparent; }.highlight Pre {background-color: #f8f8f8; BORDER:1PX Solid #cccccc; font-size:13px; line-height:19px; overflow:auto; PADDING:6PX 10px; border-radius:3px; }pre {background-color: #f8f8f8; BORDER:1PX Solid #cccccc; font-size:13px; line-height:19px; overflow:auto; PADDING:6PX 10px; border-radius:3px; } Pre code, pre TT {background-color:transparent; border:none; }sup {font-size:0.83em; vertical-align:super; line-height:0;} * {-webkit-print-color-adjust:exact;} @media screen and (min-width:914px) {body {width:854px; margin:0 auto; }} @media print {table, pre {page-break-inside:avoid;} Pre {word-wrap:break-word;}} --></style><style>!--/** * prism.js default theme for JavaScript, CSS and HTML * Based on dabblet (http://dabblet.com) * @author Lea Verou */code[class*= "language-"],pre[class*= "language-"] {color:black;background:none;text-shadow:0 1px white; font-family:consolas, Monaco, ' Andale mono ', ' Ubuntu mono ', monospace;text-align:left;white-space:pre;word-spacing: normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;- webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;} pre[class*= "language-"]::-moz-selection, pre[class*= "language-"]::-moz-selection,code[class*= "language-"]::- moz-selection, code[class*= "language-"]::-moz-selection {text-shadow:none;background: #b3d4fc;} pre[class*= "language-"]::selection, pre[class*= "language-"]:: selection,code[class*= "language-"]::selection, Code [class*= "language-"]:: Selection {text-shadow:none;background: #b3d4fc;} @media print {code[class*= "language-"],pre[class*= "language-"] {text-shadow:none;}} /* Code blocks */pre[class*= "language-"] {padding:1em;margin:. 5em 0;overflow:auto;}:not (pre) > code[class*= "language- "],pre[class*=" language-"{background: #f5f2f0;} /* Inline Code */:not (pre) > code[class*= "language-"] {padding:. 1em;border-radius:. 3em;white-space:normal;}. Token.comment,.token.prolog,.token.doctype,.token.cdata {color:slategray;}. Token.punctuation {color: #999;}. Namespace {opacity:. 7;}. token.property,.token.tag,.token.boolean,.token.number,.token.constant,.token.symbol,.token.deleted {color: #905 ;}. token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.inserted {color: #690;}. Token.operator,.token.entity,.token.url,.language-css. token.string,.style. token.string {color: #a67f59; Background:hsla (0, 0%, 100%,. 5);}. Token.atrule,.token.attr-value,.token.keyword {color: #07a;}. Token.function {color: #DD4A68;}. Token.regex,.token.important,.token.variable {color: #e90;}. Token.important,.token.bold {font-weight:bold;}. Token.italic {font-sTyle:italic;}. Token.entity {cursor:help;} --></style><style><style><!--pre.line-numbers {position: relative;padding-left: 3.8em;counter-reset: linenumber;}pre.line-numbers > code {position: relative;}.line-numbers .line-numbers-rows {position: absolute;pointer-events: none;top: 0;font-size: 100%;left: -3.8em;width: 3em; /* works for line-numbers below 1000 lines */letter-spacing: -1px;border-right: 1px solid #999;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}.line-numbers-rows > span {pointer-events: none;display: block;counter-increment: linenumber;}.line-numbers-rows > span:before {content: counter(linenumber);color: #999;display: block;padding-right: 0.8em;text-align: right;}--></style></style>Xutils Plug-in<p><p>The simplest method--use of the <code>xUtils</code> <code>HttpUitls</code> download file, support multi-threaded breakpoint download</p></p><p><p>Https://github.com/wyouflf/xUtils</p></p><p><p>How to Use:</p></p><pre class="line-numbers"><code class="language-none"><code class="language-none">httputils http = new Httputils (); HttpHandler handler = Http.download ("http://apache.dataguru.cn/httpcomponents/httpclient/source/ Httpcomponents-client-4.2.5-src.zip ","/sdcard/httpcomponents-client-4.2.5-src.zip ", true,//if the destination file exists, Then the unfinished section continues to Download. The server does not support range when it is newly downloaded. true,//if The file name is obtained from the request return information, it is automatically renamed after the download is Complete. New requestcallback<file> () {@Override public void OnStart () {testtextview.settext ("conn. .."); } @Override public void Onloading (long, long, boolean Isuploading) {testtextview.settext (CU Rrent + "/" + total); } @Override public void onsuccess (responseinfo<file> Responseinfo) {testtextview.settext (" Downloaded: "+ ResponseInfo.result.getPath ()); } @Override public void OnFailure (httpexception error, String msg) {testtextview.settext (msg); }});//call the Cancel () method to stop downloading Handler.cancel (); .... </code></code></pre>Implementing multi-threaded Breakpoint downloads using the HTTP protocol<p><p>Multithreading Implementation Ideas:</p></p> <ol> <ol> <li>Send an HTTP GET request to</li> <li>Gets the total length of the file, creating temporary files such as file lengths</li> <li>Calculates the start and end positions of each thread by dividing the total length of the file by the number of threads</li> <li>Turn on multi-threading and start downloading data by location</li> <li>The location of the temporary file where the downloaded data exists</li> </ol> </ol><p><p>Add Breakpoint</p></p> <ol> <ol> <li>Download the current total download length using an int variable record</li> <li>Save this variable in a temporary file while downloading</li> <li>The next download takes that location as the starting point for the Download.</li> <li>Delete temporary files after download</li> </ol> </ol><p><p>Detailed implementation Steps See: http://blog.csdn.net/guanhang89/article/details/51346790</p></p><p><p></p></p><p><p>How does the multi-threaded download of "android face question" be implemented? How do I implement a breakpoint continuation?</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.