VOOZH about

URL: https://www.geeksforgeeks.org/java/bytebuffer-position-methods-in-java-with-examples/

⇱ ByteBuffer position() methods in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

ByteBuffer position() methods in Java with Examples

Last Updated : 27 Jun, 2019
The position(int newPosition) method of java.nio.ByteBuffer Class is used to Sets this buffer's position. If the mark is defined and larger than the new position then it is discarded. Syntax:
public ByteBuffer position(int newPosition)
Parameters: This method takes the newPosition as parameter which is the new position value. It must be non-negative and no larger than the current limit. Return Value: This method returns this buffer. Below are the examples to illustrate the position() method: Examples 1:
Output:
position before reset: 4
position after reset: 2
Examples 2:
Comment