# ParsableByteArray

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/util/ParsableByteArray.java+class:androidx.media3.common.util.ParsableByteArray)

*** ** * ** ***


```
@UnstableApi
@CheckReturnValue
class ParsableByteArray
```

<br />

*** ** * ** ***

Wraps a byte array, providing a set of methods for parsing data from it. Numerical values are parsed with the assumption that their constituent bytes are in big endian order.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#INVALID_CODE_POINT() = 1114112` A value that is outside the valid range of unicode code points. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#ParsableByteArray()()` Creates a new instance that initially has no backing data. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#ParsableByteArray(byte[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Creates a new instance wrapping `data`, and sets the limit to `data.length`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#ParsableByteArray(int)(limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates a new instance with `limit` bytes and sets the limit. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#ParsableByteArray(byte[],int)(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates a new instance that wraps an existing array. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#bytesLeft()()` Returns the number of bytes yet to be read. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#capacity()()` Returns the capacity of the array, which may be larger than the limit. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#ensureCapacity(int)(requiredCapacity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Ensures the backing array is at least `requiredCapacity` long. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#isCharsetSupported(java.nio.charset.Charset)(charset: https://developer.android.com/reference/java/nio/charset/Charset.html!)` Returns whether the provided `https://developer.android.com/reference/java/nio/charset/Charset.html` is supported when passed to methods like `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekChar(java.nio.charset.Charset)` and `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLine(java.nio.charset.Charset)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#limit()()` Returns the limit. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekChar()()` Peeks at the next two bytes and interprets them as a big-endian char. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char/index.html` | `[peekChar](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekChar(java.nio.charset.Charset))(charset: https://developer.android.com/reference/java/nio/charset/Charset.html!)` **This function is deprecated.** Either use `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekChar()` to peek the next two bytes (big-endian) or `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekCodePoint(java.nio.charset.Charset)` to peek in a `https://developer.android.com/reference/java/nio/charset/Charset.html`-aware way. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekCodePoint(java.nio.charset.Charset)(charset: https://developer.android.com/reference/java/nio/charset/Charset.html!)` Peeks at the code point starting at `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getPosition()` as interpreted by `charset`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekInt()()` Peeks the next four bytes as a signed value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekUnsignedByte()()` Peeks at the next byte as an unsigned value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekUnsignedInt24()()` Peeks the next three bytes as an unsigned value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readByte()()` Reads the next byte as a signed value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readBytes(androidx.media3.common.util.ParsableBitArray,int)(bitArray: https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableBitArray!, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Reads the next `length` bytes into `bitArray`, and resets the position of ` bitArray` to zero. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readBytes(java.nio.ByteBuffer,int)(buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Reads the next `length` bytes into `buffer`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readBytes(byte[],int,int)(buffer: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Reads the next `length` bytes into `buffer` at `offset`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readDelimiterTerminatedString(char)(delimiter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char/index.html)` Reads up to the next delimiter byte (or the limit) as UTF-8 characters. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readDouble()()` Reads the next eight bytes as a 64-bit floating point value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readFloat()()` Reads the next four bytes as a 32-bit floating point value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readInt()()` Reads the next four bytes as a signed value |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readInt24()()` Reads the next three bytes as a signed value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLine()()` Reads a line of text in UTF-8. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLine(java.nio.charset.Charset)(charset: https://developer.android.com/reference/java/nio/charset/Charset.html!)` Reads a line of text in `charset`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLittleEndianInt()()` Reads the next four bytes as a signed value in little endian order. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLittleEndianInt24()()` Reads the next three bytes as a signed value in little endian order. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLittleEndianLong()()` Reads the next eight bytes as a signed value in little endian order. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-short/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLittleEndianShort()()` Reads the next two bytes as a signed value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLittleEndianUnsignedInt()()` Reads the next four bytes as an unsigned value in little endian order. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLittleEndianUnsignedInt24()()` Reads the next three bytes as an unsigned value in little endian order. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLittleEndianUnsignedIntToInt()()` Reads the next four bytes as a little endian unsigned integer into an integer, if the top bit is a zero. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLittleEndianUnsignedShort()()` Reads the next two bytes as an unsigned value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLong()()` Reads the next eight bytes as a signed value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readNullTerminatedString()()` Reads up to the next NUL byte (or the limit) as UTF-8 characters. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readNullTerminatedString(int)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Reads the next `length` bytes as UTF-8 characters. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-short/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readShort()()` Reads the next two bytes as a signed value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readString(int)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Reads the next `length` bytes as UTF-8 characters. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readString(int,java.nio.charset.Charset)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, charset: https://developer.android.com/reference/java/nio/charset/Charset.html!)` Reads the next `length` bytes as characters in the specified `https://developer.android.com/reference/java/nio/charset/Charset.html`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readSynchSafeInt()()` Reads a Synchsafe integer. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readUnsignedByte()()` Reads the next byte as an unsigned value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readUnsignedFixedPoint1616()()` Reads the next four bytes, returning the integer portion of the fixed point 16.16 integer. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readUnsignedInt()()` Reads the next four bytes as an unsigned value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readUnsignedInt24()()` Reads the next three bytes as an unsigned value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readUnsignedIntToInt()()` Reads the next four bytes as an unsigned integer into an integer, if the top bit is a zero. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readUnsignedLeb128ToInt()()` Reads an unsigned variable-length [LEB128](https://en.wikipedia.org/wiki/LEB128) value into an int. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readUnsignedLeb128ToLong()()` Reads an unsigned variable-length [LEB128](https://en.wikipedia.org/wiki/LEB128) value into a long. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readUnsignedLongToLong()()` Reads the next eight bytes as an unsigned long into a long, if the top bit is a zero. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readUnsignedShort()()` Reads the next two bytes as an unsigned value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readUtf8EncodedLong()()` Reads a long value encoded by UTF-8 encoding |
| `https://developer.android.com/reference/java/nio/charset/Charset.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readUtfCharsetFromBom()()` Reads a UTF byte order mark (BOM) and returns the UTF `https://developer.android.com/reference/java/nio/charset/Charset.html` it represents. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#reset(byte[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Updates the instance to wrap `data`, and resets the position to zero and the limit to `data.length`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#reset(int)(limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Resets the position to zero and the limit to the specified value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#reset(byte[],int)(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Updates the instance to wrap `data`, and resets the position to zero. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#setLimit(int)(limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the limit. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/VisibleForTesting [setShouldEnforceLimitOnLegacyMethods](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#setShouldEnforceLimitOnLegacyMethods(java.lang.Boolean))(enforceLimit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html?)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Flags#enableFlag(int)` or `https://developer.android.com/reference/kotlin/androidx/media3/common/Flags#disableFlag(int)` with `https://developer.android.com/reference/kotlin/androidx/media3/common/Flags#FLAG_ENFORCE_PARSABLE_BYTE_ARRAY_LIMIT()` instead. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#skipBytes(int)(bytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Moves the reading offset by `bytes`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#skipLeb128()()` Skips a variable-length [LEB128](https://en.wikipedia.org/wiki/LEB128) value. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#data()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#position()` |

## Constants

### INVALID_CODE_POINT

```
const val INVALID_CODE_POINT = 1114112: Int
```

A value that is outside the valid range of unicode code points.

## Public constructors

### ParsableByteArray

```
ParsableByteArray()
```

Creates a new instance that initially has no backing data.

### ParsableByteArray

```
ParsableByteArray(data: ByteArray<Byte>!)
```

Creates a new instance wrapping `data`, and sets the limit to `data.length`.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The array to wrap. |

### ParsableByteArray

```
ParsableByteArray(limit: Int)
```

Creates a new instance with `limit` bytes and sets the limit.

| Parameters |
|---|---|
| `limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The limit to set. |

### ParsableByteArray

```
ParsableByteArray(data: ByteArray<Byte>!, limit: Int)
```

Creates a new instance that wraps an existing array.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The data to wrap. |
| `limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The limit to set. |

## Public functions

### bytesLeft

```
fun bytesLeft(): Int
```

Returns the number of bytes yet to be read.

### capacity

```
fun capacity(): Int
```

Returns the capacity of the array, which may be larger than the limit.

### ensureCapacity

```
fun ensureCapacity(requiredCapacity: Int): Unit
```

Ensures the backing array is at least `requiredCapacity` long.

`https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getPosition()`, `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#limit()`, and all data in the underlying array (including that beyond `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#limit()`) are preserved.

This might replace or wipe the `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getData()`, potentially invalidating any local references.

### isCharsetSupported

```
java-static fun isCharsetSupported(charset: Charset!): Boolean
```

Returns whether the provided `https://developer.android.com/reference/java/nio/charset/Charset.html` is supported when passed to methods like `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekChar(java.nio.charset.Charset)` and `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLine(java.nio.charset.Charset)`.

### limit

```
fun limit(): Int
```

Returns the limit.

### peekChar

```
fun peekChar(): Char
```

Peeks at the next two bytes and interprets them as a big-endian char.

### peekChar

```
fun [peekChar](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekChar(java.nio.charset.Charset))(charset: Charset!): Char
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Either use `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekChar()` to peek the next two bytes (big-endian) or `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#peekCodePoint(java.nio.charset.Charset)` to peek in a `https://developer.android.com/reference/java/nio/charset/Charset.html`-aware way.

### peekCodePoint

```
fun peekCodePoint(charset: Charset!): Int
```

Peeks at the code point starting at `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getPosition()` as interpreted by `charset`.

The exact behaviour depends on `charset`:

- US_ASCII: Returns the byte at `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getPosition()` if it's valid ASCII (less than `0x80`), otherwise returns `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#INVALID_CODE_POINT()`.
- UTF-8: If `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getPosition()` is the start of a UTF-8 code unit the whole unit is decoded and returned. Otherwise `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#INVALID_CODE_POINT()` is returned.
- UTF-16 (all endian-nesses):
  - If `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getPosition()` is at the start of a `https://developer.android.com/reference/java/lang/Character.html#isHighSurrogate(char)` code unit and the following two bytes are a `https://developer.android.com/reference/java/lang/Character.html#isLowSurrogate(char)` low surrogate} code unit, the `https://developer.android.com/reference/java/lang/Character.html#toCodePoint(char, char)` is returned.
  - Otherwise the single code unit starting at `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getPosition()` is returned directly.
  - UTF-16 has no support for byte-level synchronization, so if `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getPosition()` is not aligned with the start of a UTF-16 code unit then the result is undefined.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if charset is not supported. Only US_ASCII, UTF-8, UTF-16, UTF-16BE, and UTF-16LE are supported. |
| `https://developer.android.com/reference/java/lang/IndexOutOfBoundsException.html` | if `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#bytesLeft()` doesn't allow reading the smallest code unit in `charset` (1 byte for ASCII and UTF-8, 2 bytes for UTF-16). |

### peekInt

```
fun peekInt(): Int
```

Peeks the next four bytes as a signed value.

### peekUnsignedByte

```
fun peekUnsignedByte(): Int
```

Peeks at the next byte as an unsigned value.

### peekUnsignedInt24

```
fun peekUnsignedInt24(): Int
```

Peeks the next three bytes as an unsigned value.

### readByte

```
fun readByte(): Byte
```

Reads the next byte as a signed value.

### readBytes

```
fun readBytes(bitArray: ParsableBitArray!, length: Int): Unit
```

Reads the next `length` bytes into `bitArray`, and resets the position of `
bitArray` to zero.

| Parameters |
|---|---|
| `bitArray: https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableBitArray!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableBitArray` into which the bytes should be read. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes to write. |

### readBytes

```
fun readBytes(buffer: ByteBuffer!, length: Int): Unit
```

Reads the next `length` bytes into `buffer`.

| Parameters |
|---|---|
| `buffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!` | The `https://developer.android.com/reference/java/nio/ByteBuffer.html` into which the read data should be written. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes to read. |

| See also |
|---|---|
| `https://developer.android.com/reference/java/nio/ByteBuffer.html#put(byte[], int, int)` |   |

### readBytes

```
fun readBytes(buffer: ByteArray<Byte>!, offset: Int, length: Int): Unit
```

Reads the next `length` bytes into `buffer` at `offset`.

| Parameters |
|---|---|
| `buffer: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The array into which the read data should be written. |
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The offset in `buffer` at which the read data should be written. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes to read. |

| See also |
|---|---|
| `https://developer.android.com/reference/java/lang/System.html#arraycopy(java.lang.Object, int, java.lang.Object, int, int)` |   |

### readDelimiterTerminatedString

```
fun readDelimiterTerminatedString(delimiter: Char): String?
```

Reads up to the next delimiter byte (or the limit) as UTF-8 characters.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The string not including any terminating delimiter byte, or null if the end of the data has already been reached. |

### readDouble

```
fun readDouble(): Double
```

Reads the next eight bytes as a 64-bit floating point value.

### readFloat

```
fun readFloat(): Float
```

Reads the next four bytes as a 32-bit floating point value.

### readInt

```
fun readInt(): Int
```

Reads the next four bytes as a signed value

### readInt24

```
fun readInt24(): Int
```

Reads the next three bytes as a signed value.

### readLine

```
fun readLine(): String?
```

Reads a line of text in UTF-8.

Equivalent to passing `https://developer.android.com/reference/java/nio/charset/StandardCharsets.html#UTF_8` to `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#readLine(java.nio.charset.Charset)`.

### readLine

```
fun readLine(charset: Charset!): String?
```

Reads a line of text in `charset`.

A line is considered to be terminated by any one of a carriage return ('\\r'), a line feed ('\\n'), or a carriage return followed immediately by a line feed ('\\r\\n'). This method discards leading UTF byte order marks (BOM), if present.

The `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getPosition()` is advanced to start of the next line (i.e. any line terminators are skipped).

| Parameters |
|---|---|
| `charset: https://developer.android.com/reference/java/nio/charset/Charset.html!` | The charset used to interpret the bytes as a `https://developer.android.com/reference/java/lang/String.html`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The line not including any line-termination characters, or null if the end of the data has already been reached. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if charset is not supported. Only US_ASCII, UTF-8, UTF-16, UTF-16BE, and UTF-16LE are supported. |

### readLittleEndianInt

```
fun readLittleEndianInt(): Int
```

Reads the next four bytes as a signed value in little endian order.

### readLittleEndianInt24

```
fun readLittleEndianInt24(): Int
```

Reads the next three bytes as a signed value in little endian order.

### readLittleEndianLong

```
fun readLittleEndianLong(): Long
```

Reads the next eight bytes as a signed value in little endian order.

### readLittleEndianShort

```
fun readLittleEndianShort(): Short
```

Reads the next two bytes as a signed value.

### readLittleEndianUnsignedInt

```
fun readLittleEndianUnsignedInt(): Long
```

Reads the next four bytes as an unsigned value in little endian order.

### readLittleEndianUnsignedInt24

```
fun readLittleEndianUnsignedInt24(): Int
```

Reads the next three bytes as an unsigned value in little endian order.

### readLittleEndianUnsignedIntToInt

```
fun readLittleEndianUnsignedIntToInt(): Int
```

Reads the next four bytes as a little endian unsigned integer into an integer, if the top bit is a zero.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | Thrown if the top bit of the input data is set. |

### readLittleEndianUnsignedShort

```
fun readLittleEndianUnsignedShort(): Int
```

Reads the next two bytes as an unsigned value.

### readLong

```
fun readLong(): Long
```

Reads the next eight bytes as a signed value.

### readNullTerminatedString

```
fun readNullTerminatedString(): String?
```

Reads up to the next NUL byte (or the limit) as UTF-8 characters.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | The string not including any terminating NUL byte, or null if the end of the data has already been reached. |

### readNullTerminatedString

```
fun readNullTerminatedString(length: Int): String!
```

Reads the next `length` bytes as UTF-8 characters. A terminating NUL byte is discarded, if present.

| Parameters |
|---|---|
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes to read. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The string, not including any terminating NUL byte. |

### readShort

```
fun readShort(): Short
```

Reads the next two bytes as a signed value.

### readString

```
fun readString(length: Int): String!
```

Reads the next `length` bytes as UTF-8 characters.

| Parameters |
|---|---|
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes to read. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The string encoded by the bytes. |

### readString

```
fun readString(length: Int, charset: Charset!): String!
```

Reads the next `length` bytes as characters in the specified `https://developer.android.com/reference/java/nio/charset/Charset.html`.

| Parameters |
|---|---|
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes to read. |
| `charset: https://developer.android.com/reference/java/nio/charset/Charset.html!` | The character set of the encoded characters. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The string encoded by the bytes in the specified character set. |

### readSynchSafeInt

```
fun readSynchSafeInt(): Int
```

Reads a Synchsafe integer.

Synchsafe integers keep the highest bit of every byte zeroed. A 32 bit synchsafe integer can store 28 bits of information.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The parsed value. |

### readUnsignedByte

```
fun readUnsignedByte(): Int
```

Reads the next byte as an unsigned value.

### readUnsignedFixedPoint1616

```
fun readUnsignedFixedPoint1616(): Int
```

Reads the next four bytes, returning the integer portion of the fixed point 16.16 integer.

### readUnsignedInt

```
fun readUnsignedInt(): Long
```

Reads the next four bytes as an unsigned value.

### readUnsignedInt24

```
fun readUnsignedInt24(): Int
```

Reads the next three bytes as an unsigned value.

### readUnsignedIntToInt

```
fun readUnsignedIntToInt(): Int
```

Reads the next four bytes as an unsigned integer into an integer, if the top bit is a zero.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | Thrown if the top bit of the input data is set. |

### readUnsignedLeb128ToInt

```
fun readUnsignedLeb128ToInt(): Int
```

Reads an unsigned variable-length [LEB128](https://en.wikipedia.org/wiki/LEB128) value into an int.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | integer value |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the read value is greater than `https://developer.android.com/reference/java/lang/Integer.html#MAX_VALUE` or less than `https://developer.android.com/reference/java/lang/Integer.html#MIN_VALUE` |

### readUnsignedLeb128ToLong

```
fun readUnsignedLeb128ToLong(): Long
```

Reads an unsigned variable-length [LEB128](https://en.wikipedia.org/wiki/LEB128) value into a long.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | long value |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the byte to be read is over the limit of the parsable byte array |

### readUnsignedLongToLong

```
fun readUnsignedLongToLong(): Long
```

Reads the next eight bytes as an unsigned long into a long, if the top bit is a zero.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | Thrown if the top bit of the input data is set. |

### readUnsignedShort

```
fun readUnsignedShort(): Int
```

Reads the next two bytes as an unsigned value.

### readUtf8EncodedLong

```
fun readUtf8EncodedLong(): Long
```

Reads a long value encoded by UTF-8 encoding

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Decoded long value |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NumberFormatException.html` | if there is a problem with decoding |

### readUtfCharsetFromBom

```
fun readUtfCharsetFromBom(): Charset?
```

Reads a UTF byte order mark (BOM) and returns the UTF `https://developer.android.com/reference/java/nio/charset/Charset.html` it represents. Returns `null` without advancing `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getPosition()` if no BOM is found.

### reset

```
fun reset(data: ByteArray<Byte>!): Unit
```

Updates the instance to wrap `data`, and resets the position to zero and the limit to `data.length`.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The array to wrap. |

### reset

```
fun reset(limit: Int): Unit
```

Resets the position to zero and the limit to the specified value. This might replace or wipe the `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getData()`, potentially invalidating any local references.

| Parameters |
|---|---|
| `limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The limit to set. |

### reset

```
fun reset(data: ByteArray<Byte>!, limit: Int): Unit
```

Updates the instance to wrap `data`, and resets the position to zero.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The array to wrap. |
| `limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The limit to set. |

### setLimit

```
fun setLimit(limit: Int): Unit
```

Sets the limit.

| Parameters |
|---|---|
| `limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The limit to set. |

### setShouldEnforceLimitOnLegacyMethods

```
@VisibleForTesting
java-static fun [setShouldEnforceLimitOnLegacyMethods](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#setShouldEnforceLimitOnLegacyMethods(java.lang.Boolean))(enforceLimit: Boolean?): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Flags#enableFlag(int)` or `https://developer.android.com/reference/kotlin/androidx/media3/common/Flags#disableFlag(int)` with `https://developer.android.com/reference/kotlin/androidx/media3/common/Flags#FLAG_ENFORCE_PARSABLE_BYTE_ARRAY_LIMIT()` instead.

Sets whether all read/peek methods should enforce that `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getPosition()` never exceeds `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#limit()`.

Setting this to `true` can help catch cases of accidentally reading beyond `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#limit()` but still within the bounds of the underlying `https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray#getData()`.

Some (newer) methods will always enforce the invariant, even when this is set to `
false`.

Defaults to `null`, which means a default value is used (which may change in a later release).

### skipBytes

```
fun skipBytes(bytes: Int): Unit
```

Moves the reading offset by `bytes`.

| Parameters |
|---|---|
| `bytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes to skip. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | Thrown if the new position is neither in nor at the end of the array. |

### skipLeb128

```
fun skipLeb128(): Unit
```

Skips a variable-length [LEB128](https://en.wikipedia.org/wiki/LEB128) value.

## Public properties

### data

```
val data: Array<Byte>!
```

### position

```
var position: Int
```