Java Convert via ByteBuffer intArrayToIntBuffer(int[] data)

Here you can find the source of intArrayToIntBuffer(int[] data)

Description

Converts an array of primitive ints to a java.nio.IntBuffer .

License

Open Source License

Parameter

Parameter Description
data The int array to convert.

Return

Returns the form of the int array.

Declaration

public static IntBuffer intArrayToIntBuffer(int[] data) 

Method Source Code

//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;
    }
}

Related

  1. hexToBytes(String hexStr)
  2. hexToBytes(String hexString)
  3. intArrayFromBytes(byte[] bytes)
  4. intArrayToByteArray(int[] intArray)
  5. intArrayToBytes(Collection values)
  6. intsToBytes(int[] n)
  7. IntToBArray(int src)
  8. intToByte(int[] intArray)
  9. intToByteArray(int integer)