Code example for IntBuffer

Methods: position, put

0
	public static IntBuffer getIntegerBuffer(int[] list) {
		ByteBuffer bb = ByteBuffer.allocateDirect(list.length * Integer.SIZE/8);
		bb.order(ByteOrder.nativeOrder());
		IntBuffer ib = bb.asIntBuffer();
		 
		ib.put(list);
		ib.position(0);
		return ib;
	} 
	 
	public static ShortBuffer getShortBuffer(short[] list) {
		ByteBuffer bb = ByteBuffer.allocateDirect(list.length * Short.SIZE/8);
		bb.order(ByteOrder.nativeOrder());
		ShortBuffer sb = bb.asShortBuffer();
		 
		sb.put(list);
		sb.position(0);
		return sb;
	} 
	 
}