Using java to realize HTTP multithreading breakpoint download file (1)
Basic principle: use urlconnection to obtain the length, header and other relevant information of the file to be downloaded, and set the header information of the response. The input stream is obtained through urlconnection, and the file is divided into specified blocks. Each block opens up a thread to read and write data. Read the information of the downloaded file through the input stream, and then randomly write the read information to the local file with RandomAccessFile. At the same time, the data written by each thread is the file pointer, that is, the length of the written data, which needs to be saved in a temporary file. In this way, when this download is not completed, the length of the last downloaded file will be read from this file next time, and then continue to download from the last location. And write the length of this download to this file. 1、 The download file information class and entity encapsulate the information of the resource to be downloaded