Read data from the underlying input stream into the read buffer.
359323
protected function loadBuffer()
	{
		$this->buffer = '';
	
		if($this->finished)
		{
			return;
		}
		
		while(!$this->stream->eof() && strlen($this->buffer) < $this->chunkSize)
		{
			$this->buffer .= $this->stream->read($this->chunkSize - strlen($this->buffer));
		}
		
		if($this->buffer === '')
		{
			$this->finished = true;
			$this->buffer .= "0\r\n\r\n";
		}
		else
		{
			$this->buffer = sprintf("%X\r\n%s\r\n", strlen($this->buffer), $this->buffer);
		}
	}
471291
public int read() throws IOException {
    if (this.bytesRead == this.length) {
      // All chunks and final additional chunk are read.
      // This means we have reached EOF.
      return -1;
    }

    try {
      // Read a chunk from given input stream when
      // it is first chunk or all bytes in chunk body is read
      if (this.streamBytesRead == 0 || this.chunkPos == this.chunkBody.length) {
        // Check if there are data available to read from given input stream.
        if (this.streamBytesRead != this.streamSize) {
          // Send all data chunks.
          int chunkSize = CHUNK_SIZE;
          if (this.streamBytesRead + chunkSize > this.streamSize) {
            chunkSize = this.streamSize - this.streamBytesRead;
          }

          if (readChunk(chunkSize) < 0) {
            return -1;
          }

          this.streamBytesRead += chunkSize;
        } else {
          // Send final additional chunk to complete chunk upload.
          byte[] chunk = new byte[0];
          createChunkBody(chunk);
        }
      }

      this.bytesRead++;
      // Value must be between 0 to 255.
      int value = this.chunkBody[this.chunkPos] & 0xFF;
      this.chunkPos++;
      return value;
    } catch (NoSuchAlgorithmException | InvalidKeyException | InsufficientDataException | InternalException e) {
      throw new IOException(e.getCause());
    }
  }
578562
protected int readFully(InputStream in, byte buffer[])
        throws java.io.IOException {
        for (int i = 0; i < buffer.length; i++) {
            int q = in.read();
            if (q == -1)
                return i;
            buffer[i] = (byte)q;
        }
        return buffer.length;
    }
637231
def read(self, n):
        
        buf = self._read_buf
        pos = self._read_pos
        end = pos + n

        if end <= len(buf):
            # Fast path: the data to read is fully buffered.
            self._read_pos += n
            return self._update_pos(buf[pos:end])

        # Slow path: read from the stream until enough bytes are read,
        # or until an EOF occurs or until read() would block.
        wanted = max(self.buffer_size, n)
        while len(buf) < end:
            chunk = self.raw.read(wanted)
            if not chunk:
                break
            buf += chunk

        self._read_buf = buf[end:]  # Save the extra data in the buffer.
        self._read_pos = 0
        return self._update_pos(buf[pos:end])
1363863
private static byte[] readStream(final InputStream in) throws IOException {
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    final byte[] data = new byte[4096];
    int bytesRead;
    while ((bytesRead = in.read(data, 0, data.length)) != -1) {
      bos.write(data, 0, bytesRead);
    }
    return bos.toByteArray();
  }
1114606
def _read_from_buffer(self, size=-1):
        """"""
        # logger.debug('reading %r bytes from %r byte-long buffer', size, len(self._buffer))
        size = size if size >= 0 else len(self._buffer)
        part = self._buffer.read(size)
        self._current_pos += len(part)
        # logger.debug('part: %r', part)
        return part
1267355
private byte[] read(InputStream in) throws IOException {
		ByteArrayOutputStream out = new ByteArrayOutputStream(READ_FILE_BASE_SIZE);
		byte[] buffer = new byte[READ_BUFFER_SIZE];
		int count = in.read(buffer);
		while (count != -1) {
			if (count != 0) {
				out.write(buffer, 0, count);
			}
			count = in.read(buffer);
		}
		in.close();
		return out.toByteArray();
	}
847314
public int read(byte []buf, int offset, int length) throws IOException
  {
    if (_stream != null)
      return _stream.read(buf, offset, length);
    else
      return -1;
  }
712129
private static void readFully(final DataInput input, final float[] floats) throws IOException {
        if (input instanceof ImageInputStream) {
            // Optimization for ImageInputStreams, read all in one go
            ((ImageInputStream) input).readFully(floats, 0, floats.length);
        }
        else {
            for (int i = 0; i < floats.length; i++) {
                floats[i] = input.readFloat();
            }
        }
    }
105508
public void read() throws IOException {
    readFileId();
    in.resetCRC();

    long startcode = in.readStartCode();

    while (true) {
      // Start parsing main and stream information
      header = new MainHeaderPacket();

      if (!Startcode.MAIN.equalsCode(startcode)) {
        throw new IOException(String.format("expected main header found: 0x%X", startcode));
      }

      header.read(in, startcode);
      startcode = readReservedHeaders();

      streams.clear();
      for (int i = 0; i < header.streamCount; i++) {
        if (!Startcode.STREAM.equalsCode(startcode)) {
          throw new IOException(String.format("expected stream header found: 0x%X", startcode));
        }

        StreamHeaderPacket streamHeader = new StreamHeaderPacket();
        streamHeader.read(in, startcode);

        Stream stream = new Stream(header, streamHeader);
        streams.add(stream);
        listener.stream(stream);

        startcode = readReservedHeaders();
      }

      while (Startcode.INFO.equalsCode(startcode)) {
        new Packet().read(in, startcode); // Discard for the moment
        startcode = readReservedHeaders();
      }

      if (Startcode.INDEX.equalsCode(startcode)) {
        new Packet().read(in, startcode); // Discard for the moment
        startcode = in.readStartCode();
      }

      // Now main frame parsing loop
      while (!Startcode.MAIN.equalsCode(startcode)) {

        if (Startcode.SYNCPOINT.equalsCode(startcode)) {
          new Packet().read(in, startcode); // Discard for the moment
          startcode = in.readStartCode();
        }

        if (Startcode.isPossibleStartcode(startcode)) {
          throw new IOException("expected framecode, found " + Startcode.toString(startcode));
        }

        Frame f = new Frame();
        f.read(this, in, (int) startcode);

        listener.frame(f);

        try {
          startcode = readReservedHeaders();
        } catch (java.io.EOFException e) {
          return;
        }
      }
    }
  }
645860
private byte[] convertInputStreamToBytes(InputStream in) throws IOException {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();

        int len;
        byte[] data = new byte[16384];

        while ((len = in.read(data, 0, data.length)) != -1) {
            buffer.write(data, 0, len);
        }

        buffer.flush();
        return buffer.toByteArray();
    }
557852
private void readMoreBytesFromStream() throws IOException {
        if (!innerStreamHasMoreData) {
            return;
        }

        int bufferSpaceAvailable = buffer.length - bytesInBuffer;
        if (bufferSpaceAvailable <= 0) {
            return;
        }

        int bytesRead =
                stream.read(buffer, bytesInBuffer, bufferSpaceAvailable);

        if (bytesRead == -1) {
            innerStreamHasMoreData = false;
        } else {
            bytesInBuffer += bytesRead;
        }
    }
1177814
def _read_stream_for_size(stream, buf_size=65536):
    """"""
    size = 0
    while True:
        buf = stream.read(buf_size)
        size += len(buf)
        if not buf:
            break
    return size
520933
public static void readFully(Reader reader, char[] buffer, int offset) throws IOException {
    int originalOffset = offset;
    int expected = buffer.length - offset;
    while (offset < buffer.length) {
      int numRead = reader.read(buffer, offset, buffer.length - offset);
      if (numRead < 0) {
        throw new IOException(
                String.format("Reached end of stream earlier than expected. Expected to read %d bytes. Actual: %d",
                expected, offset - originalOffset));
      }
      offset += numRead;
    }
  }
28218
public void read(ByteBuffer buffer) {
        Persistables.persistable(streamableNoBuffers()).read(buffer);

        final int n = getNumDataBuffers();
        int lengthsPosition = buffer.position();
        buffer.position(buffer.position() + 2 * n); // skip positions
        for (int i = 0; i < n; i++) {
            final int size = buffer.getShort(lengthsPosition) & 0xFFFF; // big-endian
            lengthsPosition += 2;

            final ByteBuffer b1 = Persistables.slice(buffer, size);
            setDataBuffer(i, b1);
        }
    }
746114
async def read(self, *, decode: bool=False) -> Any:
        
        if self._at_eof:
            return b''
        data = bytearray()
        while not self._at_eof:
            data.extend((await self.read_chunk(self.chunk_size)))
        if decode:
            return self.decode(data)
        return data
1084632
def read(self,size):
    """"""
    done = 0 #number of bytes that have been read so far
    v = ''
    while True:
      if size-done < len(self._buffer['data']) - self._buffer_pos:
        v +=  self._buffer['data'][self._buffer_pos:self._buffer_pos+(size-done)]
        self._buffer_pos += (size-done)
        #self.pointer += size
        return v
      else: # we need more buffer
        vpart = self._buffer['data'][self._buffer_pos:]
        self._buffer = self._load_block()
        v += vpart
        self._buffer_pos = 0
        if len(self._buffer['data'])==0: return v
        done += len(vpart)