다음을 통해 공유


ByteBuffer.AlignedSlice(Int32) Method

Definition

Creates a new byte buffer whose content is a shared and aligned subsequence of this buffer's content.

[Android.Runtime.Register("alignedSlice", "(I)Ljava/nio/ByteBuffer;", "", ApiSince=33)]
public Java.Nio.ByteBuffer AlignedSlice (int unitSize);
[<Android.Runtime.Register("alignedSlice", "(I)Ljava/nio/ByteBuffer;", "", ApiSince=33)>]
member this.AlignedSlice : int -> Java.Nio.ByteBuffer

Parameters

unitSize
Int32

The unit size in bytes, must be a power of 2

Returns

The new byte buffer

Attributes

Remarks

Creates a new byte buffer whose content is a shared and aligned subsequence of this buffer's content.

The content of the new buffer will start at this buffer's current position rounded up to the index of the nearest aligned byte for the given unit size, and end at this buffer's limit rounded down to the index of the nearest aligned byte for the given unit size. If rounding results in out-of-bound values then the new buffer's capacity and limit will be zero. If rounding is within bounds the following expressions will be true for a new buffer nb and unit size unitSize:

{@code
            nb.alignmentOffset(0, unitSize) == 0
            nb.alignmentOffset(nb.limit(), unitSize) == 0
            }

Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer or fewer subject to alignment, its mark will be undefined, and its byte order will be ByteOrder#BIG_ENDIAN BIG_ENDIAN.

The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

Added in 9.

Java documentation for java.nio.ByteBuffer.alignedSlice(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to