users@grizzly.java.net

Re: Simple input manipulation

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Tue, 20 May 2008 14:03:26 +0200

Hello Wayne,

can you provide complete source of your Filter? As here I don't see
how you get the buffer :)

>
> I'm doing this bit by bit and I have a wierd problem with reading
> the buffer
> into a string.
> Heres a code snippet.
> <code>
> SelectableChannel channel = ctx.getSelectionKey().channel();
> try {
>
> CharBuffer cbuf = buffer.asCharBuffer();
> while(cbuf.hasRemaining())
> System.out.print(cbuf.get());
Does this print what you need?

>
>
> cbuf.flip();
> String tmp = cbuf.toString();
> System.out.println(tmp);
And blank squares are printed just here?

>
>
> OutputWriter.flushChannel(channel, buffer);
> channel.close();
> }
> </code>
>
> To me that should printout the same buffer twice and then echo the
> output to
> the channel. The System.out.println output makes a bunch of squares
> could
> this be an encoding problem?
Not sure. Think CharBuffer.toString() should work properly.

Thanks.

WBR,
Alexey.
>
>
> --
> Regards
> Wayne
> Cell: 27 (0)83 666 3342
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>