flip(): This method is available in java.nio.ByteBuffer class of Java.
Syntax:
ByteBuffer java.nio.ByteBuffer.flip()
This method 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. This method is often used in conjunction with the compact method when transferring data from one place to another.
Parameters: NA
Returns: This buffer.
Exceptions: NA
Approach
Java
import java.nio.ByteBuffer;public class ByteBufferflip {public static void main(String[] args) {byte array[] = { 1, 2, 3, 4 };ByteBuffer bb = ByteBuffer.wrap(array);ByteBuffer flip = bb.flip();System.out.println(flip);}}
Output:
java.nio.HeapByteBuffer[pos=0 lim=0 cap=4]
No comments:
Post a Comment