Code example for ByteBuffer

Methods: clear, flip

0
    } 
 
    @Override 
    public boolean pump(int timeout)
            throws IOException, InterruptedException { 
        buffer.clear();
        int cb = channel.read(buffer);
        if (cb == -1)
            return false; 
        buffer.flip();
        send(buffer);
        return true; 
    } 
 
}