Package libcore.io

Class HeapBufferIterator


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

      All Methods Static Methods Instance Methods Concrete Methods 
      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.
    • Method Detail

      • 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.