new Int Buffer - Java java.nio

Java examples for java.nio:IntBuffer

Description

new Int Buffer

Demo Code


//package com.java2s;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import java.nio.IntBuffer;

public class Main {
    public static void main(String[] argv) throws Exception {
        int paramInt = 2;
        System.out.println(newIntBuffer(paramInt));
    }//from www . j  a v a 2 s .co  m

    public static IntBuffer newIntBuffer(int paramInt) {
        ByteBuffer localByteBuffer = newByteBuffer(paramInt * 4);
        return localByteBuffer.asIntBuffer();
    }

    public static ByteBuffer newByteBuffer(int paramInt) {
        ByteBuffer localByteBuffer = ByteBuffer.allocateDirect(paramInt);
        localByteBuffer.order(ByteOrder.nativeOrder());
        return localByteBuffer;
    }
}

Related Tutorials