Check the input buffer for data. If necessary, attempt a read for a new
buffer.

@return boolean - true means data is ready
@throws IOException
197936
protected boolean checkBuffer() throws IOException {
        if (!enableMultiReadofPostData) {
            if (null != this.buffer) {
                if (this.buffer.hasRemaining()) {
                    return true;
                }
                this.buffer.release();
                this.buffer = null;
            }
            try {
                this.buffer = this.isc.getRequestBodyBuffer();
                if (null != this.buffer) {
                    // record the new amount of data read from the channel
                    this.bytesRead += this.buffer.remaining();
                    // Tr.debug(tc, "Buffer=" + WsByteBufferUtils.asString(this.buffer));
                    return true;
                }
                return false;
            } catch (IOException e) {
                this.error = e;
                throw e;
            }
        } else {
            return checkMultiReadBuffer();
        }
    }
1231831
public function hasDataToRead()
    {
        if (!$this->isConnected()) {
            throw new ConnectionException('Not connected to any server.', $this->activeHost);
        }

        $isDataInBuffer = $this->connectionHasDataToRead($this->readTimeout[0], $this->readTimeout[1]);
        if (!$isDataInBuffer) {
            $this->observers->emptyBuffer();
        }
        return $isDataInBuffer;
    }
192857
public function hasData()
    {
        if ( count( $this->files ) >= 1 )
        {
            if ( $this->files[0] === 'php://stdin' || filesize( $this->files[0] ) > 0 )
            {
                return true;
            }
        }
        return false;
    }
282912
private void handleReadBuffer() throws IOException {
        if (readBuffer.remaining() == 0) {
            readBuffer.clear();
            actualFile.read(actualFileOffset, readBuffer);
            actualFileOffset += readBuffer.limit();
            readBuffer.position(0);
        }
    }
422133
public int read() throws IOException {
    while (true) {
      lockR.lock();
      try {
        if (availableCount.get() > 0) {
          // as long as there is available data
          // serve it even if closed
          int b = bytes[readCursor] & 0xFF;
          incReadCursor(1);
          availableCount.decrementAndGet();
          totalRead++;
          return b;
        } else if (closed){
          // when no bytes are left and buffer is closed
          // return -1
          return -1;
        }
      } finally {
        lockR.unlock();
      }
      sleep(1);
    }
  }
697122
private void getConnInput() throws IOException
  {
    if (_didGet)
      return;

    try {
      getConnInputImpl();
    } catch (IOException e) {
      _isKeepalive = false;
      throw e;
    } catch (RuntimeException e) {
      _isKeepalive = false;
      throw e;
    }
  }
135458
protected synchronized int read() throws IOException {
		try {
			block();
		} catch (InterruptedException ex) {
			throw new InterruptedIOException(
					"The blocking operation was interrupted");
		}

		if (closed && available() <= 0) {
			return -1;
		}

		return buf[readpos++];

	}
396441
@Override
    public int read() throws IOException {
        
        //Return -1 here because if we are closed or finished, we're at the end of the stream
        if(isClosed || isFinished()){
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Nothing to read, stream is closed : " + isClosed + ", or finished : " + isFinished());
            return -1;
        }
        
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "read" , "SRTInputStream31.read()");
        }
        
        int returnByte;
        
        if(this.request.isAsyncStarted()&& (this.getReadListener()!= null)){
            synchronized(this){
//                Check if isReady had returned false. If it did then an IllegalArgumentException will be thrown if a listener is set
                isReadyFalseCheck();
                returnByte = super.read();
            }
        } else{
            returnByte = super.read();
        }
        
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "read" , "SRTInputStream31.read() : " + returnByte);
        }
        
        return returnByte;
    }
877535
private boolean readNextLine() throws IOException {
        boolean newLine = false;
        if (bufferLimit > 0 && !bufferLineEnd) {
            // check for "last line"
            if (bufferLimit < buffer.length) {
                return false;
            }
        } else {
            newLine = true;
        }

        bufferLineEnd = false;

        int off = 0;
        char[] b = new char[1];
        while (off < buffer.length && reader.read(b, 0, 1) > 0) {
            final char ch = b[0];
            buffer[off] = ch;
            ++off;
            if (ch == '\n') {
                bufferLineEnd = true;
                break;
            }
        }
        if (off > 0) {
            if (newLine) {
                ++lineNo;
                linePos = 0;
            }
            if (off < buffer.length) {
                buffer[off] = 0;
            }
            bufferOffset = -1;
            bufferLimit = off;
            return true;
        }
        return false;
    }
261179
public int read() throws IOException {
        validate();
        int rc = -1;
        
        if(doRead(1)){
            rc = _buffer.get() & 0x000000FF;
        }

        _buffer.release();
        _buffer = null;
            
        return rc;
    }
626489
private boolean refill() throws IOException {
    if (!byteBuffer.hasRemaining()) {
      byteBuffer.clear();
      int nRead = 0;
      while (nRead == 0) {
        nRead = fileChannel.read(byteBuffer);
      }
      if (nRead < 0) {
        return false;
      }
      byteBuffer.flip();
    }
    return true;
  }
1206892
public boolean isEmpty() throws IOException {
    Closer closer = Closer.create();
    try {
      InputStream in = closer.register(openStream());
      return in.read() == -1;
    } catch (Throwable e) {
      throw closer.rethrow(e);
    } finally {
      closer.close();
    }
  }
420357
public byte readByte()
            throws IOException {
        // Buffer depleted ?
        if (head == tail) {
            head = 0;
            // Refill.
            tail = input.read(buffer, head, bufSize);
            if (tail == -1) {
                // No more data available.
                throw new IOException("No more data is available");
            }
            if(notifier != null) {
                notifier.noteBytesRead(tail);
            }
        }
        return buffer[head++];
    }
691046
public function onRead()
    {
        if ($this->state === self::STATE_PREHANDSHAKE) {
            if ($this->getInputLength() < 8) {
                return;
            }
            $this->key = $this->readUnlimited();
            $this->handshake();
        }
        if ($this->state === self::STATE_HANDSHAKED) {
            while (($buflen = $this->getInputLength()) >= 2) {
                $hdr = $this->look(10);
                $frametype = ord(mb_orig_substr($hdr, 0, 1));
                if (($frametype & 0x80) === 0x80) {
                    $len = 0;
                    $i = 0;
                    do {
                        if ($buflen < $i + 1) {
                            // not enough data yet
                            return;
                        }
                        $b = ord(mb_orig_substr($hdr, ++$i, 1));
                        $n = $b & 0x7F;
                        $len *= 0x80;
                        $len += $n;
                    } while ($b > 0x80);

                    if ($this->pool->maxAllowedPacket <= $len) {
                        // Too big packet
                        $this->finish();
                        return;
                    }

                    if ($buflen < $len + $i + 1) {
                        // not enough data yet
                        return;
                    }
                    $this->drain($i + 1);
                    $this->onFrame($this->read($len), 'BINARY');
                } else {
                    if (($p = $this->search("\xFF")) !== false) {
                        if ($this->pool->maxAllowedPacket <= $p - 1) {
                            // Too big packet
                            $this->finish();
                            return;
                        }
                        $this->drain(1);
                        $data = $this->read($p);
                        $this->drain(1);
                        $this->onFrame($data, 'STRING');
                    } else {
                        if ($this->pool->maxAllowedPacket < $buflen - 1) {
                            // Too big packet
                            $this->finish();
                            return;
                        }
                        // not enough data yet
                        return;
                    }
                }
            }
        }
    }
142824
def _ready(self):
        
        # if DOUT pin is low, data is ready for reading
        _is_ready = GPIO.input(self._dout) == 0
        logging.debug("check data ready for reading: {result}".format(
            result="YES" if _is_ready is True else "NO"
        ))
        return _is_ready
70936
private void checkSystemInput()
        throws IOException
    {
        while ( System.in.available() > 0 )
        {
            int input = System.in.read();
            if ( input >= 0 )
            {
                char c = (char) input;
                if ( c == '\n' )
                {
                    synchronized ( lock )
                    {
                        finished = true;
                        lock.notifyAll();
                    }
                }
            }
            else
            {
                synchronized ( lock )
                {
                    finished = true;
                    lock.notifyAll();
                }
            }
        }
    }
422585
public void readData(DataInput input) throws IOException {
        readReference = input.readUnsignedShort();
        readCount = input.readUnsignedShort();
        writeReference = input.readUnsignedShort();
        writeCount = input.readUnsignedShort();
        int byteCount = input.readUnsignedByte();

        if (nonWordDataHandler == null) {
            byte buffer[] = new byte[byteCount];
            input.readFully(buffer, 0, byteCount);

            int offset = 0;
            registers = new Register[writeCount];

            for (int register = 0; register < writeCount; register++) {
                registers[register] = new SimpleRegister(buffer[offset], buffer[offset + 1]);
                offset += 2;
            }
        }
        else {
            nonWordDataHandler.readData(input, writeReference, writeCount);
        }
    }