The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Bulk put(int) for ByteBuffer

I am not quite sure this is the right sub-forum for my question but the other ones didnt seem to be correct either. If I am in fact at the wrong place I apologize in advance.

Now to my little problem with a direct ByteBuffer.

I am trying to put an array of int values into a ByteBuffer but the ByteBuffer does not offer a method to do so directly.
My own performance tests have shown, that iterating through an int array and putting each int individually leads to drastic performance loss compared to using an IntBuffer and putting the entire array at once.
But performance is very important in this specific part of my application and to keep the code clean I would prefer to only use ByteBuffers.

So my question is, what exactly is the correct way of realising a bulk put method for ints on a ByteBuffer with good performance?
Or is there any fast and efficient way to cast an IntBuffer into a ByteBuffer maybe?