create IntBuffer by size - Android java.nio

Android examples for java.nio:IntBuffer

Description

create IntBuffer by size

Demo Code


import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

public class Main{
    public static final IntBuffer createIntBuffer(int size) {
        return ByteBuffer
                .allocateDirect(size * DatatypeUtils.INTEGER_SIZE_BYTES)
                .order(ByteOrder.nativeOrder()).asIntBuffer();
    }//  w  ww .  ja va 2s.c  o m
}

Related Tutorials