public static byte[] byteBufferToBytes(ByteBuffer buffer) {
        final byte[] array = buffer.array();
        final int arrayOffset = buffer.arrayOffset();
        return Arrays.copyOfRange(array, arrayOffset + buffer.position(),
                arrayOffset + buffer.limit());
    }
public static byte [ ] byteBufferToBytes ( ByteBuffer buffer ) { final byte [ ] array = buffer . array ( ) ; final int arrayOffset = buffer . arrayOffset ( ) ; return Arrays . copyOfRange ( array , arrayOffset + buffer . position ( ) , arrayOffset + buffer . limit ( ) ) ; }
@param buffer the buffer to convert
@return the bytes of the buffer