public static IntBuffer toBuffer ( int ... arr ) { ByteBuffer directBuffer = ByteBuffer . allocateDirect ( arr . length * 4 ) . order ( ByteOrder . nativeOrder ( ) ) ; IntBuffer buffer = directBuffer . asIntBuffer ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) buffer . put ( i , arr [ i ] ) ; return buffer ; }
Convert an array to a byte buffer