Search in sources :

Example 1 with DownloadRange

use of zlc.season.rxdownload2.entity.DownloadRange in project RxDownload by ssseasonnn.

the class FileHelper method readDownloadRange.

public DownloadRange readDownloadRange(File tempFile, int i) throws IOException {
    RandomAccessFile record = null;
    FileChannel channel = null;
    try {
        record = new RandomAccessFile(tempFile, ACCESS);
        channel = record.getChannel();
        MappedByteBuffer buffer = channel.map(READ_WRITE, i * EACH_RECORD_SIZE, (i + 1) * EACH_RECORD_SIZE);
        long startByte = buffer.getLong();
        long endByte = buffer.getLong();
        return new DownloadRange(startByte, endByte);
    } finally {
        closeQuietly(channel);
        closeQuietly(record);
    }
}
Also used : DownloadRange(zlc.season.rxdownload2.entity.DownloadRange) RandomAccessFile(java.io.RandomAccessFile) MappedByteBuffer(java.nio.MappedByteBuffer) FileChannel(java.nio.channels.FileChannel)

Aggregations

RandomAccessFile (java.io.RandomAccessFile)1 MappedByteBuffer (java.nio.MappedByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1 DownloadRange (zlc.season.rxdownload2.entity.DownloadRange)1