{@inheritDoc}

@see java.nio.channels.SeekableByteChannel#read(java.nio.ByteBuffer)
188019
@Override
    public int read(final ByteBuffer destination) throws IOException {

        // Precondition checks
        this.checkClosed();
        if (destination == null) {
            throw new IllegalArgumentException("Destination buffer must be supplied");
        }

        // Init
        final int spaceInBuffer = destination.remaining();
        final int numBytesRemainingInContent, numBytesToRead;

        // Sync up before getting at shared mutable state
        synchronized (this) {
            numBytesRemainingInContent = this.contents.length - this.position;

            // Set position was greater than the size? Just return.
            if (numBytesRemainingInContent <= 0) {
                return -1;
            }

            // We'll read in either the number of bytes remaining in content or the amount of space in the buffer,
            // whichever is smaller
            numBytesToRead = numBytesRemainingInContent >= spaceInBuffer ? spaceInBuffer : numBytesRemainingInContent;
            // Copy a sub-array of the bytes we'll put into the buffer
            destination.put(this.contents, this.position, numBytesToRead);

            // Set the new position
            this.position += numBytesToRead;
        }

        // Return the number of bytes read
        return numBytesToRead;
    }
358995
@Override
  public int read(byte []buffer, int offset, int length) throws IOException
  {
    int sublen = getDelegate().read(buffer, offset, length);
    
    if (sublen > 0) {
      logStream().write(buffer, offset, sublen);
    }
    
    return sublen;
  }
557178
@Override
	public int read(byte[] b, int off, int len) throws IOException {
		int numread = this.in.read(b, off, len);
		if (numread > 0) {
			this.inputBytesRead += numread;
		}
		return numread;
	}
1240757
@Override
    public int read(byte[] b, int byteOffset, int byteLength)
            throws IOException
    {
        int writtenBytes = 0;
        for (; writtenBytes < byteLength; ) {

            if (uncompressedCursor >= uncompressedLimit) {
                if (hasNextChunk()) {
                    continue;
                }
                else {
                    return writtenBytes == 0 ? -1 : writtenBytes;
                }
            }
            int bytesToWrite = Math.min(uncompressedLimit - uncompressedCursor, byteLength - writtenBytes);
            System.arraycopy(uncompressed, uncompressedCursor, b, byteOffset + writtenBytes, bytesToWrite);
            writtenBytes += bytesToWrite;
            uncompressedCursor += bytesToWrite;
        }

        return writtenBytes;
    }
479230
@Nonnegative
  public long read (@Nonnull final ByteBuffer aDestByteBuffer)
  {
    ValueEnforcer.notNull (aDestByteBuffer, "DestByteBuffer");

    _checkClosed ();
    long nBytesRead = 0;
    while (m_nBufferIndex < m_aBuffers.length)
    {
      final ByteBuffer aByteBuffer = m_aBuffers[m_nBufferIndex];
      if (aByteBuffer.hasRemaining ())
        nBytesRead += ByteBufferHelper.transfer (aByteBuffer, aDestByteBuffer, false);
      if (!aDestByteBuffer.hasRemaining ())
        break;
      // Try next ByteBuffer
      ++m_nBufferIndex;
    }
    return nBytesRead;
  }
62915
public NioClient read(ByteBuffer buffer) {
		try {
			this.channel.read(buffer);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
		return this;
	}
328586
@Override
    public int read(byte[] out, final int off, final int len) throws IOException {
        if (off < 0 || len < 0 || (off + len) > out.length) {
            throw new IllegalArgumentException(String.format(
                    "Illegal arguments for read: byte[%d], off:%d, len:%d",
                    out.length, off, len));
        }

        final int end = off + len;
        int pos = off;
        int i;
        while (pos < end && (i = in.read(out, off, end - off)) >= 0) {
            pos += i;
        }
        return pos - off;
    }
1314753
@Override
	public int read(byte[] b) throws IOException {
		int numread = this.in.read(b);
		if (numread > 0) {
			this.inputBytesRead += numread;
		}
		return numread;
	}
535328
@Override
    public int read(byte[] output, int offset, int length) throws IOException {
        synchronized(this){
            int value = 0;
            if(closed) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
                    Tr.error(tc, "stream.is.closed.no.read.write");
                throw new IOException(Tr.formatMessage(tc, "stream.is.closed.no.read.write"));
            }
            if(output == null){
                if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
                    Tr.error(tc, "read.write.bytearray.null");
                throw new NullPointerException(Tr.formatMessage(tc, "read.write.bytearray.null"));
            }
            if((offset < 0) || (length < 0) || (length > (output.length - offset))){
                if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
                    Tr.error(tc, "read.write.offset.length.bytearraylength", new Object[] {offset, length, output.length});
                throw new IndexOutOfBoundsException(Tr.formatMessage(tc, "read.write.offset.length.bytearraylength", new Object[] {offset, length, output.length}));
            }

            if (this._inBuffer != null) {
                value = _inBuffer.read(output, offset, length);
            }
            else {
                value = this.in.read(output, offset, length);
            }

            return value;
        }
    }
414805
@Override
    public int read(byte[] buf, int off, int len) throws TTransportException
    {
        return inputTransport.read(buf, off, len);
    }
566661
public int read(byte []buffer, int offset, int length)
    throws IOException
  {
    return _file.read(buffer, offset, length);
  }
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;
        }
    }
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;
    }
515978
public synchronized int read(byte[] buf, int offset, int length) 
        throws IOException
    {

        if (!waitForContent())
            return -1;
            
         if (length>_buffer.remaining())
            length=_buffer.remaining();
            
         _buffer.get(buf, offset, length);
        return length;
    }
25474
@Override
    public int read(byte[] b) throws IOException {
        int count = origStream.read(b);
        os.write(b, 0, count);
        return count;
    }
522048
public static int read(ReadableByteChannel channel, ByteBuffer buffer) throws IOException {
        int count = channel.read(buffer);
        if (count == -1) throw new EOFException("Received -1 when reading from channel, socket has likely been closed.");
        return count;
    }
1067892
public static ByteBuffer blockingRead(SocketChannel so, long timeout, byte[] bytes) throws IOException
	{
		ByteBuffer b = ByteBuffer.wrap(bytes);

		if (bytes.length == 0)
			return b;

		final long timeoutTime = (timeout > 0) ? (System.currentTimeMillis() + timeout) : (Long.MAX_VALUE);

		while (b.remaining() != 0 && System.currentTimeMillis() < timeoutTime)
		{
			if (!so.isConnected())
				throw new IOException("Socket closed during read operation!");

			so.read(b);

			if (b.remaining() != 0)
			{
				// sleep for a short time
				try
				{
					Thread.sleep(20);
				}
				catch (InterruptedException e)
				{
				}
			}
		}

		if (System.currentTimeMillis() >= timeoutTime)
		{
			return null;
		}

		b.rewind(); // make it easy for the caller to read from the buffer (if they're interested)

		return b;
	}