Code example for MappedByteBuffer

Methods: limitpositionget

0
     * @param off int offset 
     * @param len int length 
     * @return int bytes read or -1 on EOF 
     */ 
    public int read(byte bytes[], int off, int len) {
        int pos = mappedByteBuffer.position();
        int limit = mappedByteBuffer.limit();
        if (pos == limit)
            return -1; // EOF 
        int newlimit = pos + len - off;
        if (newlimit > limit) {
            len = limit - pos; // don't read beyond EOF
        } 
        mappedByteBuffer.get(bytes, off, len);
        return len;
    } 
     
    /** 
     * @see java.io.RandomAccessFile#getFilePointer() 
     * @return long 
Stop searching for code, let great code find you!  Add Codota to your java IDE