private byte[] getByteBufferArray(ByteBuffer byteBuffer, int size) {
        byte[] b;
        if (byteBuffer.hasArray()) {
            b = byteBuffer.array();
        } else {
            b = new byte[size];
            byteBuffer.get(b, 0, size);
        }
        return b;
    }
Get a byte array from a byte buffer.
@param byteBuffer the  byte buffer
@param size the size of the resulting array
@return
jme3-core/src/plugins/java/com/jme3/texture/plugins/ktx/KTXWriter.java