tuweni / org.apache.tuweni.bytes / Bytes / slice

slice

open fun slice(i: Int): Bytes! (source)

Create a new value representing (a view of) a slice of the bytes of this value.

Please note that the resulting slice is only a view and as such maintains a link to the underlying full value. So holding a reference to the returned slice may hold more memory than the slide represents. Use #copy on the returned slice if that is not what you want.

Parameters

i - Int: The start index for the slice.

Exceptions

IndexOutOfBoundsException - if i < 0.

Return
Bytes!: A new value providing a view over the bytes from index i (included) to the end.

abstract fun slice(i: Int, length: Int): Bytes! (source)

Create a new value representing (a view of) a slice of the bytes of this value.

Please note that the resulting slice is only a view and as such maintains a link to the underlying full value. So holding a reference to the returned slice may hold more memory than the slide represents. Use #copy on the returned slice if that is not what you want.

Parameters

i - Int: The start index for the slice.

length - Int: The length of the resulting value.

Exceptions

IllegalArgumentException - if length < 0.

IndexOutOfBoundsException - if i < 0 or {i >= size()} or {i + length > size()} .

Return
Bytes!: A new value providing a view over the bytes from index i (included) to i + length (excluded).