Skip a specified number of bytes, i.e., advance the buffer's position. - Java java.nio

Java examples for java.nio:ByteBuffer

Description

Skip a specified number of bytes, i.e., advance the buffer's position.

Demo Code


//package com.java2s;

import java.nio.ByteBuffer;

public class Main {
    /**//ww w.  j a  va 2  s  .  com
     * Skip a specified number of bytes, i.e., advance the buffer's position.
     *
     * @param buf The {@link ByteBuffer} to change the position of.
     * @param count The number of bytes to skip.
     * @throws IllegalArgumentException if the buffer's current position plus
     * the count is either negative or greater than the buffer's limit.
     */
    public static void skipBytes(ByteBuffer buf, int count) {
        buf.position(buf.position() + count);
    }
}

Related Tutorials