Sdílet prostřednictvím


Buffer.Flip Method

Definition

Flips this buffer.

[Android.Runtime.Register("flip", "()Ljava/nio/Buffer;", "GetFlipHandler")]
public virtual Java.Nio.Buffer? Flip ();
[<Android.Runtime.Register("flip", "()Ljava/nio/Buffer;", "GetFlipHandler")>]
abstract member Flip : unit -> Java.Nio.Buffer
override this.Flip : unit -> Java.Nio.Buffer

Returns

This buffer

Attributes

Remarks

Flips this buffer. The limit is set to the current position and then the position is set to zero. If the mark is defined then it is discarded.

After a sequence of channel-read or put operations, invoke this method to prepare for a sequence of channel-write or relative get operations. For example:

<blockquote>

buf.put(magic);    // Prepend header
            in.read(buf);      // Read data into rest of buffer
            buf.flip();        // Flip buffer
            out.write(buf);    // Write header + data to channel

</blockquote>

This method is often used in conjunction with the java.nio.ByteBuffer#compact compact method when transferring data from one place to another.

Java documentation for java.nio.Buffer.flip().

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