240
个人博客地址: olook.me

NIO中的Buffer

public abstract class Buffer {

    // Invariants: mark <= position <= limit <= capacity
    private int mark = -1;
    private int position = 0;
    private int limit;
    private int capacity;

    // Used only by direct buffers
    // NOTE: hoisted here for speed in JNI GetDirectBufferAddress
    long address;
   ......

 

clear

 public final Buffer clear() {
        position = 0;
        limit = capacity;
        mark = -1;
        return this;
    }

 

flip

 public final Buffer flip() {
        limit = position;
        position = 0;
        mark = -1;
        return this;
    }

 

rewind

public final Buffer rewind() {
        position = 0;
        mark = -1;
        return this;
    }

 

posted @ 2017-07-03 11:09  VayCi  阅读(...)  评论(...编辑  收藏