Clear the ByteBuffer to be empty in flush mode. - Java java.nio

Java examples for java.nio:ByteBuffer

Description

Clear the ByteBuffer to be empty in flush mode.

Demo Code


//package com.java2s;

import java.nio.ByteBuffer;

public class Main {
    /** Clear the buffer to be empty in flush mode.
     * The position and limit are set to 0;
     * @param buffer The buffer to clear.
     *///w  w  w.ja v a2s . c o m
    public static void clear(ByteBuffer buffer) {
        if (buffer != null) {
            buffer.position(0);
            buffer.limit(0);
        }
    }
}

Related Tutorials