网络_断点续传.断点下载

来源:互联网 发布:阿里云按量计费 编辑:程序博客网 时间:2024/05/19 12:29
//在多线程下载的基础上,
断点下载,必须建立在服务器代码支持的基础上.

多点续传只是在多线程下载的基础上,每次write 之后,把 seek 指针的long 保存下来。保存到文件。

http.setRequestProperty("Range", "bytes="+start+"-"+end);


http头属性之一,Range 
- The first 500 bytes (byte offsets 0-499, inclusive):  bytes=0-         499 
- The second 500 bytes (byte offsets 500-999, inclusive):         bytes=500-999 
- The final 500 bytes (byte offsets 9500-9999, inclusive):         bytes=-500 - Or bytes=9500- 
- The first and last bytes only (bytes 0 and 9999):  bytes=0-0,-1 
- Several legal but not canonical specifications of the second 500 
bytes (byte offsets 500-999, inclusive): 
bytes=500-600,601-999 

bytes=500-700,601-999 


以后有时间再丰富一下内容.

而断点上传,一般都是自己写的服务器支持.因为断点下载只是http服务协议的一部分.

1 0