Code example for IntBuffer

Methods: positionput

0
	 
	public static IntBuffer makeIntBuffer(int[] ints) {
		ByteBuffer bb = ByteBuffer.allocateDirect(ints.length * INT_SIZE);
		bb.order(ByteOrder.nativeOrder());
		IntBuffer ib = bb.asIntBuffer();
		ib.put(ints);
		ib.position(0);
		return ib;
	} 
	 
	public static ShortBuffer makeShortBuffer(short[] shorts) {
		ByteBuffer bb = ByteBuffer.allocateDirect(shorts.length * SHORT_SIZE);
		bb.order(ByteOrder.nativeOrder());
		ShortBuffer sb = bb.asShortBuffer();
		sb.put(shorts);
		sb.position(0);
		return sb;
	} 
 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE