正好复习下API rewind public final Buffer rewind() Rewinds this buffer. The position is set to zero and the is discarded. Invoke this method before a sequence of channel-write or get operations, assuming that the limit has already been set appropriately. For example: out.write(buf); // Write remaining data buf.rewind(); // Rewind buffer buf.get(array); // Copy data into arrayReturns: This buffer 就拿这个例子来说 out.write(buf); // 写剩下的数据 buf.rewind(); // 把position调到零位,为了从buf的开始位置开始读入数据 buf.get(array); // 将buf中的所有数据输入array
rewind
public final Buffer rewind()
Rewinds this buffer. The position is set to zero and the is discarded.
Invoke this method before a sequence of channel-write or get operations, assuming that the limit has already been set appropriately. For example: out.write(buf); // Write remaining data
buf.rewind(); // Rewind buffer
buf.get(array); // Copy data into arrayReturns:
This buffer
就拿这个例子来说
out.write(buf); // 写剩下的数据
buf.rewind(); // 把position调到零位,为了从buf的开始位置开始读入数据
buf.get(array); // 将buf中的所有数据输入array