public boolean fillIfLive(long timeout) throws IOException {
  StreamImpl source=_source;
  byte[] readBuffer=_readBuffer;
  if (readBuffer == null || source == null) {
    _readOffset=0;
    _readLength=0;
    return false;
  }
  if (_readOffset > 0) {
    System.arraycopy(readBuffer,_readOffset,readBuffer,0,_readLength - _readOffset);
    _readLength-=_readOffset;
    _readOffset=0;
  }
  if (_readLength == readBuffer.length)   return true;
  int readLength=source.readTimeout(_readBuffer,_readLength,_readBuffer.length - _readLength,timeout);
  if (readLength >= 0) {
    _readLength+=readLength;
    _position+=readLength;
    if (_isEnableReadTime)     _readTime=CurrentTime.currentTime();
    return true;
  }
 else   if (readLength == READ_TIMEOUT) {
    return true;
  }
 else {
    return false;
  }
}

public boolean fillIfLive ( long timeout ) throws IOException { StreamImpl source = _source ; byte [ ] readBuffer = _readBuffer ; if ( readBuffer == null || source == null ) { _readOffset = 0 ; _readLength = 0 ; return false ; } if ( _readOffset > 0 ) { System . arraycopy ( readBuffer , _readOffset , readBuffer , 0 , _readLength - _readOffset ) ; _readLength -= _readOffset ; _readOffset = 0 ; } if ( _readLength == readBuffer . length ) return true ; int readLength = source . readTimeout ( _readBuffer , _readLength , _readBuffer . length - _readLength , timeout ) ; if ( readLength >= 0 ) { _readLength += readLength ; _position += readLength ; if ( _isEnableReadTime ) _readTime = CurrentTime . currentTime ( ) ; return true ; } else if ( readLength == READ_TIMEOUT ) { return true ; } else { return false ; } }
fills the buffer with a timed read , testing for the end of file . used for cases like comet to test if the read stream has closed .
