Added support for direct buffers by removing the use of bb.array()

I made some Java changes to support direct buffer that do not have an array, i removed all references to bb.array().length and replaced it by bb.capacity() and also removed the use of bb.array() and replaced it but ByteBuffer put and get operations.