ByteBuffer
public final Buffer flip() {
limit = position;
position = 0;// diff
mark = -1;
return this;
}
rewind
比flip
方法少了position = 0;
,比如在 buffer 中填满了数据,就可以使用rewind
因为此时limit = position
(limit
已经等于position
了)
public final Buffer rewind() {
position = 0;
mark = -1;
return this;
}
System.arraycopy(hb, ix(position()), hb, ix(0), remaining());
position(remaining());
limit(capacity());
discardMark();
return this;