users@grizzly.java.net

Simple input manipulation

From: Wayne Gemmell <wayne_at_flashmedia.co.za>
Date: Tue, 20 May 2008 11:22:21 +0200

Hi all

I'm trying to setup a service that reads in small XML strings, processes the
input and returns an output.

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());
              
                cbuf.flip();
                String tmp = cbuf.toString();
                System.out.println(tmp);
                
                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?

-- 
Regards
Wayne 
Cell:	27 (0)83 666 3342