public static ByteBuffer allocateDirect ( int capacity ) { ByteBuffer buf = ByteBuffer . allocateDirect ( capacity ) ; buf . limit ( 0 ) ; return buf ; }
Allocate ByteBuffer in flush mode . The position and limit will both be zero indicating that the buffer is empty and in flush mode .