Here you can find the source of intArrayToIntBuffer(int[] data)
Parameter | Description |
---|---|
data | The int array to convert. |
public static IntBuffer intArrayToIntBuffer(int[] data)
//package com.java2s; /**//from ww w . ja v a 2 s. c o m * The MIT License (MIT) * Wrath Utils Copyright (c) 2016 Trent Spears */ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; public class Main { /** * Converts an array of primitive ints to a {@link java.nio.IntBuffer}. * @param data The int array to convert. * @return Returns the {@link java.nio.IntBuffer} form of the int array. */ public static IntBuffer intArrayToIntBuffer(int[] data) { IntBuffer ret = ByteBuffer.allocateDirect(data.length << 2).order(ByteOrder.nativeOrder()).asIntBuffer(); ret.put(data).flip(); return ret; } }