1
这里是我的意思是:如何重新使用ByteBuffer将多个512字节的块写入套接字?
put 512 bytes
SocketChannel#write(this data)
start at the beginning and put 512 bytes again
rinse & repeat
我还在努力把握的ByteBuffers,我已经使用ByteBuffer#reset()
尝试,但我总是得到一个InvalidMarkException,尽管这似乎是正确的解决方案(除非我错误,我不会感到惊讶!)
谢谢!
编辑:具体来说,我试图达到同样的效果,除了我想发送它在512字节的块而不是散装。 http://privatepaste.com/1fb0e6df07
+1翻转()的任何不成文可能是适当的。 –
它说不是所有的ByteBuffers都支持reset()?你是否对InputStream.reset()感到困惑? – EJP
@EJP的确在考虑InputStreams。他得到一个InvalidMarkException,因为他没有设置标记。 – Kayaman