Java tutorial
import java.nio.ByteBuffer; import java.nio.InvalidMarkException; public class Main { public static void main(String[] args) { ByteBuffer bb = ByteBuffer.allocate(8); System.out.println("Capacity: " + bb.capacity()); System.out.println("Limit: " + bb.limit()); System.out.println("Position: " + bb.position()); // The mark is not set for a new buffer. Calling the // reset() method throws a runtime exception if the mark is not set. try { bb.reset(); System.out.println("Mark: " + bb.position()); } catch (InvalidMarkException e) { System.out.println("Mark is not set"); } } }