【发布时间】:2014-02-24 22:49:18
【问题描述】:
似乎无法在 java 文档中找到答案:
SocketChannel.read(ByteBuffer) 是追加还是覆盖当前的ByteBuffer?
【问题讨论】:
-
Reads a sequence of bytes from this channel into the given buffer. Suppose that a byte sequence of length n is read, where 0 <= n <= r. This byte sequence will be transferred into the buffer so that the first byte in the sequence is at index p and the last byte is at index p + n - 1, where p is the buffer's position at the moment this method is invoked. Upon return the buffer's position will be equal to p + n; its limit will not have changed.
标签: java sockets bytebuffer socketchannel