Reading bytes from ChannelBuffer, writing with RandomAccessFile

Bertrand Goetzmann bertrand.goetzmann at gmail.com
Mon Sep 21 03:48:23 EDT 2009


Thank you a lot.
- Bertrand

2009/9/21 Trustin Lee <trustin at gmail.com>

>
> 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.
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20090921/1bdd1df4/attachment.html 


More information about the netty-users mailing list