Package libcore.io

Class HeapBufferIterator

java.lang.Object
libcore.io.BufferIterator
libcore.io.HeapBufferIterator

public final class HeapBufferIterator
extends BufferIterator
Iterates over big- or little-endian bytes in a Java byte[].
  • Method Summary

    Modifier and Type Method Description
    static BufferIterator iterator​(byte[] buffer, int offset, int byteCount, ByteOrder order)
    Returns a new iterator over buffer, starting at offset and continuing for byteCount bytes.
    byte readByte()
    Returns the byte at the current position, and advances the current position one byte.
    void readByteArray​(byte[] dst, int dstOffset, int byteCount)
    Copies byteCount bytes from the current position into dst, starting at dstOffset, and advances the current position byteCount bytes.
    int readInt()
    Returns the 32-bit int at the current position, and advances the current position four bytes.
    void readIntArray​(int[] dst, int dstOffset, int intCount)
    Copies intCount 32-bit ints from the current position into dst, starting at dstOffset, and advances the current position 4 * intCount bytes.
    short readShort()
    Returns the 16-bit short at the current position, and advances the current position two bytes.
    void seek​(int offset)
    Seeks to the absolute position offset, measured in bytes from the start.
    void skip​(int byteCount)
    Skips forwards or backwards byteCount bytes from the current position.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • seek

      public void seek​(int offset)
      Description copied from class: BufferIterator
      Seeks to the absolute position offset, measured in bytes from the start.
      Specified by:
      seek in class BufferIterator
    • skip

      public void skip​(int byteCount)
      Description copied from class: BufferIterator
      Skips forwards or backwards byteCount bytes from the current position.
      Specified by:
      skip in class BufferIterator
    • readByteArray

      public void readByteArray​(byte[] dst, int dstOffset, int byteCount)
      Description copied from class: BufferIterator
      Copies byteCount bytes from the current position into dst, starting at dstOffset, and advances the current position byteCount bytes.
      Specified by:
      readByteArray in class BufferIterator
    • readByte

      public byte readByte()
      Description copied from class: BufferIterator
      Returns the byte at the current position, and advances the current position one byte.
      Specified by:
      readByte in class BufferIterator
    • readInt

      public int readInt()
      Description copied from class: BufferIterator
      Returns the 32-bit int at the current position, and advances the current position four bytes.
      Specified by:
      readInt in class BufferIterator
    • readIntArray

      public void readIntArray​(int[] dst, int dstOffset, int intCount)
      Description copied from class: BufferIterator
      Copies intCount 32-bit ints from the current position into dst, starting at dstOffset, and advances the current position 4 * intCount bytes.
      Specified by:
      readIntArray in class BufferIterator
    • readShort

      public short readShort()
      Description copied from class: BufferIterator
      Returns the 16-bit short at the current position, and advances the current position two bytes.
      Specified by:
      readShort in class BufferIterator
    • iterator

      public static BufferIterator iterator​(byte[] buffer, int offset, int byteCount, ByteOrder order)
      Returns a new iterator over buffer, starting at offset and continuing for byteCount bytes. Items larger than a byte are interpreted using the given byte order.