multi-threaded download steps:
1. Be aware of the size of the server-side resources.
The server URL is fetched through the URLConnection request.
urlconnection.getcontentlength ();//The size of the resource
2. Create a local file (placeholder) of the same size as the server resource
//file: file; mode: File pattern, RWD: write directly to the underlying device, HDD
randomaccessfile randomfile =new randomaccessfile (File file,string mode)
randomfile.setlength (long size);//Create a file as large as the server resource
3. To assign the starting and ending locations of each thread's download file.
4. Turn on the thread to perform the download
download some resources through URLConnection.
Note:
1. Need Range header, Key:range value:bytes:0-499
urlconnection.setrequestpropety ("Range", "bytes:0-499")
2. You need to set the start location for each thread where the local file is saved
randomaccessfile randomfile =new randomaccessfile (File file,string mode)
randomfile.seek (int startpostion);//The start location where the thread download is saved.
5. Be aware that each thread has been downloaded.
The principle of multi-threaded accelerated download