@Override public int read(byte[] buf,int offset,int length) throws IOException {
  try {
    if (_channel == null) {
      return -1;
    }
    int remaining=_readBuffer.remaining();
    if (remaining > 0) {
      _readBuffer.get(buf,offset,remaining);
      return remaining;
    }
    _readBuffer.clear();
    int channelRead=_channel.read(_readBuffer);
    _readBuffer.flip();
    if (channelRead < 0)     return -1;
    _readBuffer.get(buf,offset,channelRead);
    return channelRead;
  }
 catch (  InterruptedIOException e) {
    if (_throwReadInterrupts)     throw e;
    log.log(Level.FINEST,e.toString(),e);
  }
catch (  IOException e) {
    if (_throwReadInterrupts)     throw e;
    log.log(Level.FINER,e.toString(),e);
  }
  return -1;
}

@ Override public int read ( byte [ ] buf , int offset , int length ) throws IOException { try { if ( _channel == null ) { return - 1 ; } int remaining = _readBuffer . remaining ( ) ; if ( remaining > 0 ) { _readBuffer . get ( buf , offset , remaining ) ; return remaining ; } _readBuffer . clear ( ) ; int channelRead = _channel . read ( _readBuffer ) ; _readBuffer . flip ( ) ; if ( channelRead < 0 ) return - 1 ; _readBuffer . get ( buf , offset , channelRead ) ; return channelRead ; } catch ( InterruptedIOException e ) { if ( _throwReadInterrupts ) throw e ; log . log ( Level . FINEST , e . toString ( ) , e ) ; } catch ( IOException e ) { if ( _throwReadInterrupts ) throw e ; log . log ( Level . FINER , e . toString ( ) , e ) ; } return - 1 ; }
reads bytes from the socket .
