Check for a non null and full ByteBuffer. - Java java.nio

Java examples for java.nio:ByteBuffer

Description

Check for a non null and full ByteBuffer.

Demo Code


//package com.java2s;

import java.nio.ByteBuffer;

public class Main {
    /** Check for a non null and full buffer.
     * @param buf the buffer to check//from  ww  w.  j a va  2 s  .  c  o m
     * @return true if the buffer is not null and the limit equals the capacity.
     */
    public static boolean isFull(ByteBuffer buf) {
        return buf != null && buf.limit() == buf.capacity();
    }
}

Related Tutorials