Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.nio.Buffer
java.nio.ByteBuffer
Method Summary | |
static ByteBuffer |
|
static ByteBuffer |
|
byte[] |
|
int |
|
abstract CharBuffer |
|
abstract DoubleBuffer |
|
abstract FloatBuffer |
|
abstract IntBuffer |
|
abstract LongBuffer |
|
abstract ByteBuffer |
|
abstract ShortBuffer |
|
abstract ByteBuffer |
|
int |
|
abstract ByteBuffer |
|
boolean | |
abstract byte |
|
ByteBuffer |
|
ByteBuffer |
|
abstract byte |
|
abstract char |
|
abstract char |
|
abstract double |
|
abstract double |
|
abstract float |
|
abstract float |
|
abstract int |
|
abstract int |
|
abstract long |
|
abstract long |
|
abstract short |
|
abstract short |
|
boolean |
|
int |
|
abstract boolean |
|
ByteOrder |
|
ByteBuffer | |
abstract ByteBuffer |
|
ByteBuffer |
|
ByteBuffer |
|
abstract ByteBuffer |
|
ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
abstract ByteBuffer |
|
String |
|
static ByteBuffer |
|
static ByteBuffer |
|
Methods inherited from class java.nio.Buffer | |
capacity , clear , flip , hasRemaining , isReadOnly , limit , limit , mark , position , position , remaining , reset , rewind |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static ByteBuffer allocate(int capacity)
Allocates a newByteBuffer
object with a given capacity.
public static ByteBuffer allocateDirect(int capacity)
Allocates a new direct byte buffer.
public final byte[] array()
Returns thebyte
array that backs this buffer.
- Throws:
ReadOnlyBufferException
- If this buffer is read-only.UnsupportedOperationException
- If this buffer is not backed by an accessible array.
public final int arrayOffset()
Returns the offset within this buffer's backing array of the first element.
- Throws:
ReadOnlyBufferException
- If this buffer is read-only.UnsupportedOperationException
- If this buffer is not backed by an accessible array.
public abstract CharBuffer asCharBuffer()
Creates a view of this byte buffer as a char buffer.
public abstract DoubleBuffer asDoubleBuffer()
Creates a view of this byte buffer as a double buffer.
public abstract FloatBuffer asFloatBuffer()
Creates a view of this byte buffer as a float buffer.
public abstract IntBuffer asIntBuffer()
Creates a view of this byte buffer as an integer buffer.
public abstract LongBuffer asLongBuffer()
Creates a view of this byte buffer as a long buffer.
public abstract ByteBuffer asReadOnlyBuffer()
Creates a new read-onlyByteBuffer
that shares this buffer's content.
public abstract ShortBuffer asShortBuffer()
Creates a view of this byte buffer as a short buffer.
public abstract ByteBuffer compact()
Compacts this buffer.
- Throws:
ReadOnlyBufferException
- If this buffer is read-only.
public int compareTo(ByteBuffer other)
Compares twoByteBuffer
objects.
- Throws:
ClassCastException
- If obj is not an object derived fromByteBuffer
.
public abstract ByteBuffer duplicate()
Creates a newByteBuffer
that shares this buffer's content.
public abstract byte get()
Reads thebyte
at this buffer's current position, and then increments the position.
- Throws:
BufferUnderflowException
- If there are no remainingbyte
s in this buffer.
public ByteBuffer get(byte[] dst)
This method transfersbyte
s from this buffer into the given destination array.
- Parameters:
dst
- The byte array to write into.
- Throws:
BufferUnderflowException
- If there are fewer than dst.lengthbyte
s remaining in this buffer.
public ByteBuffer get(byte[] dst, int offset, int length)
This method transfersbyte
s from this buffer into the given destination array. Before the transfer, it checks if there are fewer than lengthbyte
s remaining in this buffer.
- Parameters:
dst
- The destination arrayoffset
- The offset within the array of the firstbyte
to be written; must be non-negative and no larger than dst.length.length
- The maximum number of bytes to be written to the given array; must be non-negative and no larger than dst.length - offset.
- Throws:
BufferUnderflowException
- If there are fewer than lengthbyte
s remaining in this buffer.IndexOutOfBoundsException
- If the preconditions on the offset and length parameters do not hold.
public abstract byte get(int index)
Absolute get method.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit.
public abstract char getChar()
Relative get method for reading a character value.
- Throws:
BufferUnderflowException
- If there are fewer than two bytes remaining in this buffer.
public abstract char getChar(int index)
Absolute get method for reading a character value.
- Throws:
IndexOutOfBoundsException
- If there are fewer than two bytes remaining in this buffer
public abstract double getDouble()
Relative get method for reading a double value.
- Throws:
BufferUnderflowException
- If there are fewer than eight bytes remaining in this buffer.
public abstract double getDouble(int index)
Absolute get method for reading a double value.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit, minus seven.
public abstract float getFloat()
Relative get method for reading a float value.
- Throws:
BufferUnderflowException
- If there are fewer than four bytes remaining in this buffer.
public abstract float getFloat(int index)
Absolute get method for reading a float value.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit, minus three.
public abstract int getInt()
Relative get method for reading an integer value.
- Throws:
BufferUnderflowException
- If there are fewer than four bytes remaining in this buffer.
public abstract int getInt(int index)
Absolute get method for reading an integer value.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit, minus three.
public abstract long getLong()
Relative get method for reading a long value.
- Throws:
BufferUnderflowException
- If there are fewer than eight bytes remaining in this buffer.
public abstract long getLong(int index)
Absolute get method for reading a long value.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit, minus seven.
public abstract short getShort()
Relative get method for reading a short value.
- Throws:
BufferUnderflowException
- If index is negative or not smaller than the buffer's limit, minus one.
public abstract short getShort(int index)
Absolute get method for reading a short value.
- Throws:
IndexOutOfBoundsException
- If there are fewer than two bytes remaining in this buffer
public final boolean hasArray()
Tells whether ot not this buffer is backed by an accessiblebyte
array.
public int hashCode()
Calculates a hash code for this buffer. This is done withint
arithmetic, where ** represents exponentiation, by this formula:
s[position()] + 31 + (s[position()+1] + 30)*31**1 + ... + (s[limit()-1]+30)*31**(limit()-1)
. Where s is the buffer data. Note that the hashcode is dependent on buffer content, and therefore is not useful if the buffer content may change.
- Returns:
- the hash code
public abstract ByteBuffer put(byte b)
Writes thebyte
at this buffer's current position, and then increments the position.
- Throws:
BufferOverflowException
- If there no remainingbyte
s in this buffer.ReadOnlyBufferException
- If this buffer is read-only.
public final ByteBuffer put(byte[] src)
Writes the content of the thebyte array
src into the buffer.
- Parameters:
src
- The array to copy into the buffer.
- Throws:
BufferOverflowException
- If there is insufficient space in this buffer for the remainingbyte
s in the source array.ReadOnlyBufferException
- If this buffer is read-only.
public ByteBuffer put(byte[] src, int offset, int length)
Writes the content of the thebyte array
src into the buffer. Before the transfer, it checks if there is fewer than length space remaining in this buffer.
- Parameters:
src
- The array to copy into the buffer.offset
- The offset within the array of the first byte to be read; must be non-negative and no larger than src.length.length
- The number of bytes to be read from the given array; must be non-negative and no larger than src.length - offset.
- Throws:
BufferOverflowException
- If there is insufficient space in this buffer for the remainingbyte
s in the source array.IndexOutOfBoundsException
- If the preconditions on the offset and length parameters do not holdReadOnlyBufferException
- If this buffer is read-only.
public abstract ByteBuffer put(int index, byte b)
Absolute put method.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit.ReadOnlyBufferException
- If this buffer is read-only.
public ByteBuffer put(ByteBuffer src)
Writes the content of the theByteBUFFER
src into the buffer. Before the transfer, it checks if there is fewer thansrc.remaining()
space remaining in this buffer.
- Parameters:
src
- The source data.
- Throws:
BufferOverflowException
- If there is insufficient space in this buffer for the remainingbyte
s in the source buffer.IllegalArgumentException
- If the source buffer is this buffer.ReadOnlyBufferException
- If this buffer is read-only.
public abstract ByteBuffer putChar(char value)
Relative put method for writing a character value.
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit.
public abstract ByteBuffer putChar(int index, char value)
Absolute put method for writing a character value.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit, minus one.
public abstract ByteBuffer putDouble(double value)
Relative put method for writing a double value.
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit.
public abstract ByteBuffer putDouble(int index, double value)
Absolute put method for writing a double value.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit, minus seven.
public abstract ByteBuffer putFloat(float value)
Relative put method for writing a float value.
- Throws:
BufferOverflowException
- If there are fewer than four bytes remaining in this buffer.
public abstract ByteBuffer putFloat(int index, float value)
Relative put method for writing a float value.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit, minus three.
public abstract ByteBuffer putInt(int value)
Relative put method for writing an integer value.
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit.
public abstract ByteBuffer putInt(int index, int value)
Absolute put method for writing an integer value.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit, minus three.
public abstract ByteBuffer putLong(int index, long value)
Absolute put method for writing a float value.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit, minus seven.
public abstract ByteBuffer putLong(long value)
Relative put method for writing a long value.
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit.
public abstract ByteBuffer putShort(int index, short value)
Absolute put method for writing a short value.
- Throws:
IndexOutOfBoundsException
- If index is negative or not smaller than the buffer's limit, minus one.
public abstract ByteBuffer putShort(short value)
Relative put method for writing a short value.
- Throws:
BufferOverflowException
- If this buffer's current position is not smaller than its limit.
public abstract ByteBuffer slice()
Creates a newByteBuffer
whose content is a shared subsequence of this buffer's content.
public static final ByteBuffer wrap(byte[] array, int offset, int length)
Wraps abyte
array into aByteBuffer
object.
- Throws:
IndexOutOfBoundsException
- If the preconditions on the offset and length parameters do not hold