piece.java
来自「java版本的实现mp3搜索的完整程序。」· Java 代码 · 共 66 行
JAVA
66 行
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package biz.tbuy.huliqing.jloading.downloader;/** * * @author huliqing */public class Piece { private long start; // 起始点的指针位置 private long pos; // 当前完成度所在的指针位置 private long end; // 终结点的指针位置 public Piece(long start, long pos, long end) { this.start = start; this.pos = pos; this.end = end; } public synchronized long getEnd() { return end; } public synchronized void setEnd(long end) { this.end = end; } public synchronized long getPos() { return pos; } public synchronized void setPos(long pos) { this.pos = pos; } public synchronized long getStart() { return start; } public synchronized void setStart(long start) { this.start = start; } /** * 切割出一块新的区域 * @return */ public synchronized Piece cutPiece() { // 如果当前区块还有大于xK的数据未下载完,则允许切割出分块 long toCut = end - pos; if (toCut > (1024 * 10)) { long s; // 起点 long e; // 终点 s = (long) (pos + Math.ceil(toCut / 2)); e = end; end = s - 1; Piece piece = new Piece(s, s, e); return piece; } return null; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?