Method Summary |
|
public static ByteBuffer | allocate(int capacity) Creates a byte buffer based on a new allocated byte array. |
public static ByteBuffer | allocateDirect(int capacity) Creates a direct byte buffer based on a new allocated memory block. |
final public byte[] | array() Returns the byte array which this buffer is based on, if there's one. |
final public int | arrayOffset() Returns the offset of the byte array which this buffer is based on, if
there's one. |
abstract public CharBuffer | asCharBuffer() Returns a char buffer which is based on the remaining content of this
byte buffer.
The new buffer's position is zero, its limit and capacity is the number
of remaining bytes divided by two, and its mark is not set. |
abstract public DoubleBuffer | asDoubleBuffer() Returns a double buffer which is based on the remaining content of this
byte buffer.
The new buffer's position is zero, its limit and capacity is the number
of remaining bytes divided by two, and its mark is not set. |
abstract public FloatBuffer | asFloatBuffer() Returns a float buffer which is based on the remaining content of this
byte buffer.
The new buffer's position is zero, its limit and capacity is the number
of remaining bytes divided by two, and its mark is not set. |
abstract public IntBuffer | asIntBuffer() Returns a int buffer which is based on the remaining content of this byte
buffer.
The new buffer's position is zero, its limit and capacity is the number
of remaining bytes divided by two, and its mark is not set. |
abstract public LongBuffer | asLongBuffer() Returns a long buffer which is based on the remaining content of this
byte buffer.
The new buffer's position is zero, its limit and capacity is the number
of remaining bytes divided by two, and its mark is not set. |
abstract public ByteBuffer | asReadOnlyBuffer() Returns a readonly buffer that shares content with this buffer.
The returned buffer is guaranteed to be a new instance, even if this buffer
is readonly itself. |
abstract public ShortBuffer | asShortBuffer() Returns a short buffer which is based on the remaining content of this
byte buffer.
The new buffer's position is zero, its limit and capacity is the number
of remaining bytes divided by two, and its mark is not set. |
abstract public ByteBuffer | compact() Compacts this byte buffer.
The remaining byte s will be moved to the head of the
buffer, staring from position zero. |
public int | compareTo(ByteBuffer otherBuffer) Compare the remaining byte s of this buffer to another
byte buffer's remaining byte s. |
abstract public ByteBuffer | duplicate() Returns a duplicated buffer that shares content with this buffer.
The duplicated buffer's position, limit, capacity and mark are the same
as this buffer. |
public boolean | equals(Object other) Tests whether this byte buffer equals to another object.
If other is not a byte buffer, then false is returned.
Two byte buffers are equals if, and only if, their remaining
byte s are exactly the same. |
abstract public byte | get() Returns the byte at the current position and increase the position by 1. |
public ByteBuffer | get(byte[] dest) Reads byte s from the current position into the specified
byte array and increase the position by the number of byte s
read. |
public ByteBuffer | get(byte[] dest, int off, int len) Reads byte s from the current position into the specified
byte array, starting from the specified offset, and increase the position
by the number of byte s read. |
abstract public byte | get(int index) Returns a byte at the specified index, and the position is not changed. |
abstract public char | getChar() Returns the char at the current position and increase the position by 2.
The 2 bytes start from the current position are composed into a char
according to current byte order and returned. |
abstract public char | getChar(int index) Returns the char at the specified index.
The 2 bytes start from the specified index are composed into a char
according to current byte order and returned. |
abstract public double | getDouble() Returns the double at the current position and increase the position by
8.
The 8 bytes start from the current position are composed into a double
according to current byte order and returned. |
abstract public double | getDouble(int index) Returns the double at the specified index.
The 8 bytes start from the specified index are composed into a double
according to current byte order and returned. |
abstract public float | getFloat() Returns the float at the current position and increase the position by 4.
The 4 bytes start from the current position are composed into a float
according to current byte order and returned. |
abstract public float | getFloat(int index) Returns the float at the specified index.
The 4 bytes start from the specified index are composed into a float
according to current byte order and returned. |
abstract public int | getInt() Returns the int at the current position and increase the position by 4.
The 4 bytes start from the current position are composed into a int
according to current byte order and returned. |
abstract public int | getInt(int index) Returns the int at the specified index.
The 4 bytes start from the specified index are composed into a int
according to current byte order and returned. |
abstract public long | getLong() Returns the long at the current position and increase the position by 8.
The 8 bytes start from the current position are composed into a long
according to current byte order and returned. |
abstract public long | getLong(int index) Returns the long at the specified index.
The 8 bytes start from the specified index are composed into a long
according to current byte order and returned. |
abstract public short | getShort() Returns the short at the current position and increase the position by 2.
The 2 bytes start from the current position are composed into a short
according to current byte order and returned. |
abstract public short | getShort(int index) Returns the short at the specified index.
The 2 bytes start from the specified index are composed into a short
according to current byte order and returned. |
final public boolean | hasArray() Returns whether this buffer is based on a byte array and is read/write. |
public int | hashCode() Hash code is calculated from the remaining byte s. |
abstract public boolean | isDirect() Returns true if this buffer is direct. |
final public ByteOrder | order() Returns the byte order used by this buffer when converting
byte s from/to other primitive types. |
final public ByteBuffer | order(ByteOrder byteOrder) Sets the byte order of this buffer.
Parameters: byteOrder - The byte order to set. |
ByteBuffer | orderImpl(ByteOrder byteOrder) |
abstract byte[] | protectedArray() Child class implements this method to realize array() . |
abstract int | protectedArrayOffset() Child class implements this method to realize arrayOffset() . |
abstract boolean | protectedHasArray() Child class implements this method to realize hasArray() . |
abstract public ByteBuffer | put(byte b) Writes the given byte to the current position and increase the position
by 1. |
final public ByteBuffer | put(byte[] src) Writes byte s in the given byte array to the current
position and increase the position by the number of byte s
written. |
public ByteBuffer | put(byte[] src, int off, int len) Writes byte s in the given byte array, starting from the
specified offset, to the current position and increase the position by
the number of byte s written. |
public ByteBuffer | put(ByteBuffer src) Writes all the remaining byte s of the src
byte buffer to this buffer's current position, and increase both buffers'
position by the number of byte s copied. |
abstract public ByteBuffer | put(int index, byte b) Write a byte to the specified index of this buffer and the position is
not changed. |
abstract public ByteBuffer | putChar(char value) Writes the given char to the current position and increase the position
by 2. |
abstract public ByteBuffer | putChar(int index, char value) Write a char to the specified index of this buffer.
The char is converted to bytes using the current byte order. |
abstract public ByteBuffer | putDouble(double value) Writes the given double to the current position and increase the position
by 8. |
abstract public ByteBuffer | putDouble(int index, double value) Write a double to the specified index of this buffer.
The double is converted to bytes using the current byte order. |
abstract public ByteBuffer | putFloat(float value) Writes the given float to the current position and increase the position
by 4. |
abstract public ByteBuffer | putFloat(int index, float value) Write a float to the specified index of this buffer.
The float is converted to bytes using the current byte order. |
abstract public ByteBuffer | putInt(int value) Writes the given int to the current position and increase the position by
4. |
abstract public ByteBuffer | putInt(int index, int value) Write a int to the specified index of this buffer.
The int is converted to bytes using the current byte order. |
abstract public ByteBuffer | putLong(long value) Writes the given long to the current position and increase the position
by 8. |
abstract public ByteBuffer | putLong(int index, long value) Write a long to the specified index of this buffer.
The long is converted to bytes using the current byte order. |
abstract public ByteBuffer | putShort(short value) Writes the given short to the current position and increase the position
by 2. |
abstract public ByteBuffer | putShort(int index, short value) Write a short to the specified index of this buffer.
The short is converted to bytes using the current byte order. |
abstract public ByteBuffer | slice() Returns a sliced buffer that shares content with this buffer.
The sliced buffer's capacity will be this buffer's
remaining() , and its zero position will correspond to
this buffer's current position. |
public String | toString() Returns a string represents the state of this byte buffer. |
public static ByteBuffer | wrap(byte[] array) Creates a new byte buffer by wrapping the given byte array. |
public static ByteBuffer | wrap(byte[] array, int start, int len) Creates new a byte buffer by wrapping the given byte array. |