code: public int fillWithTimeout(long timeout)
      throws IOException
    {
      if (_readOffset < _readLength) {
        return _readLength - _readOffset;
      }
  
      if (_readBuffer == null) {
        _readOffset = 0;
        _readLength = 0;
        return -1;
      }
  
      _readOffset = 0;
      StreamImpl source = _source;
  
      if (source == null) {
        // return true on end of file
        return -1;
      }
  
      int readLength
        = source.readTimeout(_readBuffer, 0, _readBuffer.length, timeout);
  
      if (readLength > 0) {
        _readLength = readLength;
        _position += readLength;
  
        if (_isEnableReadTime) {
          _readTime = CurrentTime.currentTime();
        }
  
        return readLength;
      }
      else if (readLength == READ_TIMEOUT) {
        // timeout
        _readLength = 0;
        return 0;
      }
      else {
        // return false on end of file
        _readLength = 0;
        return -1;
      }
    }
docs: Fills the buffer with a non-blocking read.
  
  @param timeout the timeout in milliseconds for the next data
  
  @return true on data or end of file, false on timeout