Reading bytes from ChannelBuffer, writing with RandomAccessFile
Trustin Lee
trustin at gmail.com
Sun Sep 20 21:59:59 EDT 2009
Hi Bertrand,
Sorry for a late response. It slipped out of my mailbox during my recent
account migration. I hope I'm not too late.
My suggestion for writing the buffer content to a file is:
RandomAccessFile raf = ...;
ChannelBuffer buf = (ChannelBuffer) e.getMessage();
buf.readBytes(raf.getChannel(), buf.readableBytes());
HTH,
Trustin
bgoetzmann wrote:
>
> Hello,
>
> In my custom handler's messageReceived, I would like write bytes contained
> in the ChannelBuffer instance into a file using a RandomAccessFile
> instance; so, a simple approach could be (where raf is the
> RandomAccessFile reference):
>
> ChannelBuffer buf = (ChannelBuffer) e.getMessage();
> while(buf.readable()) {
> raf.writeByte(buf.readByte());
> }
>
> It works, but I think there is a more quick approach! Any idea?
>
> Thank you.
>
> Bertrand.
>
-----
— Trustin Lee, http://gleamynode.net/
--
View this message in context: http://n2.nabble.com/Reading-bytes-from-ChannelBuffer-writing-with-RandomAccessFile-tp3626803p3682670.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list