ByteBuffer class Methods in Java Part- I

java.nio.ByteBuffer

A byte buffer.

This class defines six categories of operations upon byte buffers:

1. Absolute and relative get and put methods that read and write single bytes.

2. Absolute and relative bulk get methods that transfer contiguous sequences of bytes from this buffer into an array.

3. Absolute and Relative bulk put methods that transfer contiguous sequences of bytes from a byte array or some other bytebuffer into this buffer.

4. Absolute and relative get and put methods that read and write values of other primitive types, translating them to and from sequences of bytes in particular byte order.

5.  Methods for creating view buffers, which allow a byte buffer to be viewed as a buffer containing values of some other primitive type.

6. A method for compacting a byte buffer.


Some methods of ByteBuffer class


alignedSlice(): It creates a new byte buffer whose content is a shared and aligned subsequence of this buffer's content.


alignmentOffset()It returns the memory address, pointing to the byte at the given index, modulo the given unit size.


ByteBuffer.allocate(): It allocates a new byte buffer.


ByteBuffer.allocateDirect()It allocates a new direct byte buffer.


array(): It returns the byte array that backs this buffer.


arrayOffset()It returns the offset within this buffer's backing array of the first element of the buffer.


asCharBuffer()It creates a view of this byte buffer as a char buffer.


asDoubleBuffer()It creates a view of this byte buffer as a double buffer.


asFloatBuffer()It creates a view of this byte buffer as a float buffer.


asIntBuffer()It creates a view of this byte buffer as an int buffer.


asLongBuffer()It creates a view of this byte buffer as a long buffer.


asReadOnlyBuffer()It creates a new, read-only byte buffer that shares this buffer content.


asShortBuffer()It creates a view of this byte buffer as a short buffer.


capacity()It returns this buffer's capacity.


clear()It clears this buffer.


compact(): It compacts this buffer.


compareTo()It compares this buffer to another.


duplicate()It creates a new byte buffer that shares this buffer's content.


equals()It tells whether or not this buffer is equal to another object.


flip()It flips this buffer.


Some more Methods of ByteBuffer class Part -II


Some more Methods of ByteBuffer class Part- III


No comments:

Post a Comment