Reads the variable length integer encoded a the specified offset, and
returns this length with the number of bytes read.
766672
private static int[] readUncompressedLength(byte[] compressed, int compressedOffset)
        throws CorruptionException {
        int result;
        int bytesRead = 0;
        {
            int b = compressed[compressedOffset + bytesRead++] & 0xFF;
            result = b & 0x7f;
            if ((b & 0x80) != 0) {
                b = compressed[compressedOffset + bytesRead++] & 0xFF;
                result |= (b & 0x7f) << 7;
                if ((b & 0x80) != 0) {
                    b = compressed[compressedOffset + bytesRead++] & 0xFF;
                    result |= (b & 0x7f) << 14;
                    if ((b & 0x80) != 0) {
                        b = compressed[compressedOffset + bytesRead++] & 0xFF;
                        result |= (b & 0x7f) << 21;
                        if ((b & 0x80) != 0) {
                            b = compressed[compressedOffset + bytesRead++] & 0xFF;
                            result |= (b & 0x7f) << 28;
                            if ((b & 0x80) != 0) {
                                throw new CorruptionException("last byte of compressed length int has high bit set");
                            }
                        }
                    }
                }
            }
        }
        return new int[] { result, bytesRead };
    }
649523
public static void readbytes_into(InputStream input, byte[] buffer, int offset, int length) throws IOException {
		while (length > 0) {
			int read = input.read(buffer, offset, length);
			if (read == -1)
				throw new IOException("expected more bytes in input stream");
			offset += read;
			length -= read;
		}
	}
1114147
public long readLong(final int offset) throws IOException {
        final int bytesToRead = Math.max(0, offset + 8 - used);
        if (bytesToRead > 0) {
            readMore(bytesToRead);
        }
        return ((buf[offset] & 0xffL) << 56) //
                | ((buf[offset + 1] & 0xffL) << 48) //
                | ((buf[offset + 2] & 0xffL) << 40) //
                | ((buf[offset + 3] & 0xffL) << 32) //
                | ((buf[offset + 4] & 0xffL) << 24) //
                | ((buf[offset + 5] & 0xffL) << 16) //
                | ((buf[offset + 6] & 0xffL) << 8) //
                | (buf[offset + 7] & 0xffL);
    }
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;
  }
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;
    }
727327
@Override
  public int read(byte []buf, int offset, int length)
    throws IOException
  {
    if (buf == null)
      throw new NullPointerException();
    else if (offset < 0 || buf.length < offset + length)
      throw new ArrayIndexOutOfBoundsException();

    int result = nativeRead(_fd, buf, offset, length);

    if (result > 0)
      _pos += result;

    return result;
  }
1273427
public int read(byte[] output, int offset, int length) throws IOException {
        
        int size = -1;
        validate();
        
        if (0 == length) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "read(byte[],int,int), Target length was 0");
            }
            return length;
        }
        
        if(doRead(length)){
            size = _buffer.limit() - _buffer.position();
            
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            {  
              Tr.debug(tc, "(byte[],int,int) Filling byte array, size --> " + size);         
            }
            _buffer.get(output, offset, size);
        }
        _buffer.release();
        _buffer = null;
        
        return size;
    }
727622
public static long readUnsignedLong(byte[] bytes, int offset) {
      byte b = bytes[offset++];
      long i = b & 0x7F;
      for (int shift = 7; (b & 0x80) != 0; shift += 7) {
         b = bytes[offset++];
         i |= (b & 0x7FL) << shift;
      }
      return i;
   }
773232
def _readuint(self, length, start):
        """"""
        if not length:
            raise InterpretError("Cannot interpret a zero length bitstring "
                                           "as an integer.")
        offset = self._offset
        startbyte = (start + offset) // 8
        endbyte = (start + offset + length - 1) // 8

        b = binascii.hexlify(bytes(self._datastore.getbyteslice(startbyte, endbyte + 1)))
        assert b
        i = int(b, 16)
        final_bits = 8 - ((start + offset + length) % 8)
        if final_bits != 8:
            i >>= final_bits
        i &= (1 << length) - 1
        return i
1029191
public static int readInt(byte[] bytes, int offset) {
        return (((bytes[offset + 0] & 0xff) << 24) | ((bytes[offset + 1] & 0xff) << 16)
                | ((bytes[offset + 2] & 0xff) << 8) | (bytes[offset + 3] & 0xff));
    }
673436
public int getBytes(byte[] buf, int offset, int length)
    {
        if (length>unconsumedData())
            length=unconsumedData();
        System.arraycopy(_buf,_pos,buf,offset,length);
        _pos+=length;
        return length;
    }
1248654
public static int readInt(byte[] source, int position) {
        return (source[position] & 0xFF) << 24
                | (source[position + 1] & 0xFF) << 16
                | (source[position + 2] & 0xFF) << 8
                | (source[position + 3] & 0xFF);
    }
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;
  }
127836
def _readbytes(self, length, start):
        """"""
        assert length % 8 == 0
        assert start + length <= self.len
        if not (start + self._offset) % 8:
            return bytes(self._datastore.getbyteslice((start + self._offset) // 8,
                                                      (start + self._offset + length) // 8))
        return self._slice(start, start + length).tobytes()
611808
public static int readInt(byte b[], int offset) {
    int retValue;

    retValue = ((int)b[offset++]) << 24;
    retValue |= ((int)b[offset++] & 0xff) << 16;
    retValue |= ((int)b[offset++] & 0xff) << 8;
    retValue |= (int)b[offset] & 0xff;

    return retValue;
  }
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;
    }
1122691
public byte[] readLine(int offset) throws IOException {
		int lastIndex = -1;
		int localOffset = offset;
		int read;
		do {
			read = ensureBuffer(localOffset, BUFFER_SIZE);
			if (read <= 0) {
				// EOF
				this.pos = this.buffer.length;
				return null;
			}

			// NOT EOF, search for end of line
			final int end = localOffset + read;
			for (int idx = localOffset; (lastIndex == -1) && (idx < this.buffer.length) && (idx < end); ++idx) {
				if ((this.buffer[idx] == '\n') || (this.buffer[idx] == '\r')) {
					lastIndex = idx;
				}
			}
			localOffset += read;
		}
		while (lastIndex == -1);
		this.pos = lastIndex;
		return Arrays.copyOfRange(this.buffer, offset, lastIndex);
	}