Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
似乎无法在 java 文档中找到答案:
SocketChannel.read(ByteBuffer) 是否追加或覆盖当前的 ByteBuffer?
答案在ReadableByteChannel其中SocketChannel实现的 Javadoc 中:
ReadableByteChannel
SocketChannel
尝试从通道读取最多 r 个字节,其中 r 是在调用此方法时缓冲区中剩余的字节数,即 dst.remaining()。
因此,不,它不会覆盖。