All pastes #35000 Raw Edit

gcj nio buffer

public java v1 · immutable
#35000 ·published 2005-12-27 21:54 UTC
rendered paste body
    /* client is a SocketChannel     * buf is a ByteBuffer(512)     * str is a StringBuffer(100)     */    try    {      while((rd = client.read(buf)) > 0)      {         log.debug("Read " + rd + " bytes");        buf.flip();        str.append(dec.decode(buf).toString());        buf.flip();      }    }    catch(IOException e)    {      log.error("Error reading from client "          + client.socket().getInetAddress().getHostAddress()          + ":" + client.socket().getPort(), e);            key.interestOps(key.interestOps() | SelectionKey.OP_READ);      return;    }