Here you can find the source of createIntBuffer(int size)
Parameter | Description |
---|---|
size | The size, in ints |
public static IntBuffer createIntBuffer(int size)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; public class Main { /**// w w w . ja v a 2s.c om * Constructs a direct native-order intbuffer with the specified number * of elements. * * @param size The size, in ints * * @return an IntBuffer */ public static IntBuffer createIntBuffer(int size) { return (createByteBuffer(size << 2).asIntBuffer()); } /** * Constructs a direct native-order intbuffer with the specified number * of elements. * * @param values the values * * @return an IntBuffer */ public static IntBuffer createIntBuffer(int... values) { IntBuffer buff = createIntBuffer(values.length); buff.put(values); buff.flip(); return (buff); } /** * Constructs a direct native-ordered bytebuffer with the specified size. * * @param size The size, in bytes * * @return a ByteBuffer */ public static ByteBuffer createByteBuffer(int size) { return (ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder())); } /** * Constructs a direct native-ordered bytebuffer with the specified size. * * @param values the values * * @return a ByteBuffer */ public static ByteBuffer createByteBuffer(byte... values) { ByteBuffer buff = createByteBuffer(values.length); buff.flip(); return (buff); } }