⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 piece.java

📁 一个Mp3在线搜索器
💻 JAVA
字号:
/* * 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -