Check for an empty or null ByteBuffer. - Java java.nio

Java examples for java.nio:ByteBuffer

Description

Check for an empty or null ByteBuffer.

Demo Code


//package com.java2s;

import java.nio.ByteBuffer;

public class Main {
    /** Check for an empty or null buffer.
     * @param buf the buffer to check// w  w w . ja  v a  2s .c  o  m
     * @return true if the buffer is null or empty.
     */
    public static boolean isEmpty(ByteBuffer buf) {
        return buf == null || buf.remaining() == 0;
    }
}

Related Tutorials