Reads from the given buffer into the internal byte array.
973096
@Override
  public int write(ByteBuffer src) {
    int toTransfer = Math.min(src.remaining(), data.length - offset);
    src.get(data, offset, toTransfer);
    offset += toTransfer;
    return toTransfer;
  }
7776
@Override
    public int read(byte[] buffer, int offset, int length) throws IOException {
        abortIfNeeded();
        int numBytesRead;
        // If no more bytes are available, do not read any bytes into the buffer
        if(this.virtualAvailable <= 0) {
            numBytesRead = -1;
        } else {
            // If the desired read length is greater than the number of available bytes,
            // shorten the read length to the number of available bytes.
            if(length > this.virtualAvailable) {
                // If the number of available bytes is greater than the maximum value of a 32 bit int, then
                // read as many bytes as an int can.
                length = (this.virtualAvailable < Integer.MAX_VALUE) ? (int)this.virtualAvailable : Integer.MAX_VALUE;
            }
            // Read bytes into the buffer.
            numBytesRead = this.decryptedContents.read(buffer, offset, length);
        }
        // If we were able to read bytes, decrement the number of bytes available to be read.
        if(numBytesRead != -1) {
            this.virtualAvailable -= numBytesRead;
        } else {
            // If we've reached the end of the stream, close it
            this.virtualAvailable = 0;
            close();
        }
        return numBytesRead;
    }
310732
protected int readFully(InputStream in, byte buffer[], int offset, int len)
        throws java.io.IOException {
        for (int i = 0; i < len; i++) {
            int q = in.read();
            if (q == -1)
                return ((i == 0) ? -1 : i);
            buffer[i+offset] = (byte)q;
        }
        return len;
    }
933726
protected void bufferize(byte b) {
        if (index == buffer.length) {
            byte[] newBuffer = new byte[buffer.length * 2];
            System.arraycopy(buffer, 0, newBuffer, 0, index);
            buffer = newBuffer;
        }
        buffer[index++] = b;
    }
59451
public static byte[] bufferToArray(ByteBuffer buffer) {
    if (buffer.hasArray() && buffer.arrayOffset() == 0 &&
        buffer.array().length == buffer.remaining()) {
      return buffer.array();
    } else {
      byte[] bytes = new byte[buffer.remaining()];
      buffer.get(bytes);
      return bytes;
    }
  }
1180694
public static byte[] toArray(ByteBuffer buffer) {
        if (buffer.hasArray()) {
            byte[] array = buffer.array();
            int from = buffer.arrayOffset() + buffer.position();
            return Arrays.copyOfRange(array, from, from + buffer.remaining());
        } else {
            byte[] to = new byte[buffer.remaining()];
            buffer.slice().get(to);
            return to;
        }
    }
430766
private static int readLen(ByteBuffer buffer) {
        int len = 0;
        int i = Buffers.readUByte(buffer);
        if ((i & 0x80) != 0) {
            //read one more byte.
            len |= (i & 0x7f) << 8;
            len += Buffers.readUByte(buffer);
        } else {
            len = i;
        }
        return len;
    }
755365
private boolean internalRead(Buffer buffer)
    {
        try
        {
            return !(buffer.readFrom(transport) < 0);
        }
        catch (IOException e)
        {
            logger.warn("Got an IOException in internalRead!", e);
            return false;
        }
    }
1170873
def _read_bytes(fp, buf):
    

    # Do the first read without resizing the input buffer
    offset = 0
    remaining = len(buf)
    while remaining > 0:
        l = fp.readinto((ctypes.c_char * remaining).from_buffer(buf, offset))
        if l is None or l == 0:
            return offset
        offset += l
        remaining -= l
    return offset
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();
  }
1255749
public byte decodeBuffer(InputStream in)[] throws IOException {
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        decodeBuffer(in, outStream);
        return (outStream.toByteArray());
    }
1314753
@Override
	public int read(byte[] b) throws IOException {
		int numread = this.in.read(b);
		if (numread > 0) {
			this.inputBytesRead += numread;
		}
		return numread;
	}
927944
public static void read(InputStream stream, byte[] buffer) throws IOException {
        int read = 0;
        while(read < buffer.length) {
            int newlyRead = stream.read(buffer, read, buffer.length - read);
            if(newlyRead == -1)
                throw new EOFException("Attempt to read " + buffer.length
                                       + " bytes failed due to EOF.");
            read += newlyRead;
        }
    }
358749
@Override
  public int read(byte []buf, int offset, int length) throws IOException
  {
    TempBuffer cursor = _cursor;
    
    if (cursor == null)
      return -1;

    int sublen = Math.min(length, cursor.length() - _offset);

    System.arraycopy(cursor.buffer(), _offset, buf, offset, sublen);

    if (cursor.length() <= _offset + sublen) {
      _cursor = cursor.next();

      if (_freeWhenDone) {
        cursor.next(null);
        TempBuffer.free(cursor);
        cursor = null;
      }
      _offset = 0;
    }
    else
      _offset += sublen;

    return sublen;
  }
673738
public void read(byte[] buffer) throws IOException {
        IO.read(src, buffer);
        ofs += buffer.length;
    }
899169
public synchronized int read(byte[] externalBuf, int off, int len) throws IOException {

    if (len == 0) {
      return 0;
    }

    int totalReads = 0;
    while (true) {

      //read
      if (end - pos <= 0) {
        if (len - totalReads >= buf.length) {
          //buffer length is less than asked byte and buffer is empty
          // => filling directly into external buffer
          int reads = super.read(externalBuf, off + totalReads, len - totalReads);
          if (reads <= 0) {
            return (totalReads == 0) ? -1 : totalReads;
          }
          return totalReads + reads;

        } else {

          //filling internal buffer
          fillBuffer(len - totalReads);
          if (end <= 0) {
            return (totalReads == 0) ? -1 : totalReads;
          }
        }
      }

      //copy internal value to buffer.
      int copyLength = Math.min(len - totalReads, end - pos);
      System.arraycopy(buf, pos, externalBuf, off + totalReads, copyLength);
      pos += copyLength;
      totalReads += copyLength;

      if (totalReads >= len || super.available() <= 0) {
        return totalReads;
      }
    }
  }
150375
public int read(byte []buf, int offset, int length)
    throws IOException
  {
    try {
      if (_s == null || _is == null)
        return -1;

      int readLength = _is.read(buf, offset, length);

      if (readLength >= 0)
        _totalReadBytes += readLength;

      return readLength;
    } 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;
  }