ByteBuffer, but is addressable with
long indices. Implementations are backed by one or more ByteBuffers.
Differences from ByteBuffer include:
- mark and reset are not supported
- read-only is not supported
- byte order is preserved in
duplicate()andslice().
ByteBuffer-
Method Summary
Modifier and TypeMethodDescriptiondefault SmallByteBufferCreates a view of this byte buffer as a byte buffer.default SmallDoubleBufferCreates a view of this byte buffer as a double buffer.default SmallFloatBufferCreates a view of this byte buffer as a float buffer.default SmallIntBufferCreates a view of this byte buffer as a int buffer.default SmallLongBufferCreates a view of this byte buffer as a long buffer.default SmallShortBufferCreates a view of this byte buffer as a short buffer.buffers()Returns the underlyingbuffers.longcapacity()Returns this buffer's capacity.clear()Clears this buffer.copy(long fromIndex, long toIndex) Returns a copy of a range from this buffer.Creates a new byte buffer that shares this buffer's content.flip()Flips this buffer.byteget()Relative get method.default BigByteBufferget(byte[] dst) Relative bulk get method.get(byte[] dst, int offset, int length) Relative bulk get method.byteget(long index) Absolute get method.doubleRelative get method for reading a double value.doublegetDouble(long index) Absolute get method for reading a double value.floatgetFloat()Relative get method for reading a float value.floatgetFloat(long index) Absolute get method for reading a float value.intgetInt()Relative get method for reading a int value.intgetInt(long index) Absolute get method for reading a int value.longgetLong()Relative get method for reading a long value.longgetLong(long index) Absolute get method for reading a long value.shortgetShort()Relative get method for reading a short value.shortgetShort(long index) Absolute get method for reading a short value.booleanTells whether there are any bytes between the current position and the limit.longlimit()Returns this buffer's limit.limit(long newLimit) Sets this buffer's limit.order()Retrieves this buffer's byte order.Modifies this buffer's byte order.longposition()Returns this buffer's position.position(long newPosition) Sets this buffer's position.put(byte value) Relative put method.put(byte[] src) Relative bulk put methodput(long index, byte value) Absolute put method.put(long index, ByteBuffer src, int offset, int length) Absolute bulk put method.put(ByteBuffer src) Relative bulk put methodput(BigByteBuffer src) Relative bulk put methodputDouble(double value) Relative put method for writing a double.putDouble(double[] src) Relative bulk put methodputDouble(long index, double value) Absolute put method for writing a double.putDouble(DoubleBuffer src) Relative bulk put methodputFloat(float value) Relative put method for writing a float.putFloat(float[] src) Relative bulk put methodputFloat(long index, float value) Absolute put method for writing a float.putFloat(FloatBuffer src) Relative bulk put methodputInt(int value) Relative put method for writing a int.putInt(int[] src) Relative bulk put methodputInt(long index, int value) Absolute put method for writing a int.Relative bulk put methodputLong(long value) Relative put method for writing a long.putLong(long[] src) Relative bulk put methodputLong(long index, long value) Absolute put method for writing a long.putLong(LongBuffer src) Relative bulk put methodputShort(long index, short value) Absolute put method for writing a short.putShort(short value) Relative put method for writing a short.putShort(short[] src) Relative bulk put methodputShort(ShortBuffer src) Relative bulk put methodlongReturns the number of bytes between the current position and the limit.slice()Creates a new byte buffer whose content is a shared subsequence of this buffer's content.slice(long fromIndex, long toIndex) Creates a new byte buffer whose content is a shared subsequence of this buffer's content.Creates a newByteBufferwhose content is a shared subsequence of this buffer's content.smallSlice(long fromIndex, long toIndex) Creates a newByteBufferwhose content is a shared subsequence of this buffer's content.Creates a newInputStreamwhich streams this buffer's content.
-
Method Details
-
buffers
ByteBuffer[] buffers()Returns the underlyingbuffers.- Returns:
- the underlying buffers.
-
position
long position()Returns this buffer's position.- Returns:
- The position of this buffer
-
limit
long limit()Returns this buffer's limit.- Returns:
- The limit of this buffer
-
capacity
long capacity()Returns this buffer's capacity.- Returns:
- The capacity of this buffer
-
position
Sets this buffer's position.- Parameters:
newPosition- The new position value; must be non-negative and no larger than the current limit- Returns:
- this buffer
- Throws:
IllegalArgumentException- If the preconditions onnewPositiondo not hold
-
limit
Sets this buffer's limit. If the position is larger than the new limit then it is set to the new limit.- Parameters:
newLimit- The new limit value; must be non-negative and no larger than this buffer's capacity- Returns:
- this buffer
- Throws:
IllegalArgumentException- If the preconditions onnewLimitdo not hold
-
remaining
long remaining()Returns the number of bytes between the current position and the limit.- Returns:
- The number of bytes remaining in this buffer
-
hasRemaining
boolean hasRemaining()Tells whether there are any bytes between the current position and the limit.- Returns:
trueif, and only if, there is at least one byte remaining in this buffer
-
order
ByteOrder order()Retrieves this buffer's byte order.The byte order is used when reading or writing multibyte values, and when creating buffers that are views of this byte buffer. The order of a newly-created byte buffer is always
BIG_ENDIAN.- Returns:
- This buffer's byte order
-
order
Modifies this buffer's byte order.- Parameters:
order- The new byte order, eitherBIG_ENDIANorLITTLE_ENDIAN- Returns:
- this buffer
-
duplicate
BigByteBuffer duplicate()Creates a new byte buffer that shares this buffer's content.The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit values will be independent.
The new buffer's capacity, limit, position, and byte order values will be identical to those of this buffer. The new buffer will be direct if, and only if, this buffer is direct.
- Returns:
- The new byte buffer
-
slice
BigByteBuffer slice()Creates a new byte buffer whose content is a shared subsequence of this buffer's content.The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer, and the byte order will be the same as this buffer. The new buffer will be direct if, and only if, this buffer is direct.
- Returns:
- The new byte buffer
-
slice
Creates a new byte buffer whose content is a shared subsequence of this buffer's content.- Returns:
- The new byte buffer
-
smallSlice
ByteBuffer smallSlice()Creates a newByteBufferwhose content is a shared subsequence of this buffer's content.The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer, and the byte order will be the same as this buffer. The new buffer will be direct if, and only if, this buffer is direct.
- Returns:
- The new byte buffer
-
smallSlice
Creates a newByteBufferwhose content is a shared subsequence of this buffer's content.- Returns:
- The new byte buffer
-
copy
Returns a copy of a range from this buffer.- Returns:
- a copy of a range from this buffer.
-
clear
BigByteBuffer clear()Clears this buffer. The position is set to zero and the limit is set to the capacity.This method does not actually erase the data in the buffer, but it is named as if it did because it will most often be used in situations in which that might as well be the case.
- Returns:
- This buffer
-
flip
BigByteBuffer flip()Flips this buffer. The limit is set to the current position and then the position is set to zero.- Returns:
- This buffer
-
put
Relative put method.Writes the given byte into this buffer at the current position, and then increments the position.
- Parameters:
value- The byte to be written- Returns:
- This buffer
- Throws:
BufferOverflowException- If this buffer's current position is not smaller than its limit
-
put
Absolute put method.Writes the given byte into this buffer at the given index.
- Parameters:
index- The index at which the byte will be writtenvalue- The byte value to be written- Returns:
- This buffer
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit
-
put
Relative bulk put methodThis method transfers the bytes remaining in the given source buffer into this buffer. If there are more bytes remaining in the source buffer than in this buffer, that is, if
src.remaining()>remaining(), then no bytes are transferred and aBufferOverflowExceptionis thrown.Otherwise, this method copies n =
src.remaining()bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.In other words, an invocation of this method of the form
dst.put(src)has exactly the same effect as the loopwhile (src.hasRemaining()) dst.put(src.get());except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. If this buffer and the source buffer share the same backing array or memory, then the result will be as if the source elements were first copied to an intermediate location before being written into this buffer.- Parameters:
src- The source buffer from which bytes are to be read; must not be this buffer- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer for the remaining bytes in the source bufferIllegalArgumentException- If the source buffer is this buffer
-
put
Relative bulk put methodThis method transfers the bytes remaining in the given source buffer into this buffer. If there are more bytes remaining in the source buffer than in this buffer, that is, if
src.remaining()>remaining(), then no shorts are transferred and aBufferOverflowExceptionis thrown.Otherwise, this method copies n =
src.remaining()doubles from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.In other words, an invocation of this method of the form
dst.put(src)has exactly the same effect as the loopwhile (src.hasRemaining()) dst.put(src.get());except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. If this buffer and the source buffer share the same backing array or memory, then the result will be as if the source elements were first copied to an intermediate location before being written into this buffer.- Parameters:
src- The source buffer from which bytes are to be read; must not be this buffer- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer for the remaining bytes in the source buffer
-
put
Relative bulk put methodThis method transfers the entire content of the given source byte array into this buffer.
- Parameters:
src- The source array- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer
-
put
Absolute bulk put method.This method transfers
lengthbytes into this buffer from the given source buffer, starting at the givenoffsetin the source buffer and the givenindexin this buffer. The positions of both buffers are unchanged.In other words, an invocation of this method of the form
dst.put(index, src, offset, length)has exactly the same effect as the loop
except that it first checks the consistency of the supplied parameters and it is potentially much more efficient. If this buffer and the source buffer share the same backing array or memory, then the result will be as if the source elements were first copied to an intermediate location before being written into this buffer.for (int i = offset, j = index; i < offset + length; i++, j++) dst.put(j, src.get(i));- Parameters:
index- The index in this buffer at which the first byte will be written; must be non-negative and less thanlimit()src- The buffer from which bytes are to be readoffset- The index within the source buffer of the first byte to be read; must be non-negative and less thansrc.limit()length- The number of bytes to be read from the given buffer; must be non-negative and no larger than the smaller oflimit() - indexandsrc.limit() - offset- Returns:
- This buffer
- Throws:
IndexOutOfBoundsException- If the preconditions on theindex,offset, andlengthparameters do not hold
-
get
byte get()Relative get method. Reads the byte at this buffer's current position, and then increments the position.- Returns:
- The byte at the buffer's current position
- Throws:
BufferUnderflowException- If the buffer's current position is not smaller than its limit
-
get
byte get(long index) Absolute get method. Reads the byte at the given index.- Parameters:
index- The index from which the byte will be read- Returns:
- The byte at the given index
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit
-
get
Relative bulk get method.This method transfers bytes from this buffer into the given destination array. If there are fewer bytes remaining in the buffer than are required to satisfy the request, that is, if
length>remaining(), then no bytes are transferred and aBufferUnderflowExceptionis thrown.Otherwise, this method copies
lengthbytes from this buffer into the given array, starting at the current position of this buffer and at the given offset in the array. The position of this buffer is then incremented bylength.In other words, an invocation of this method of the form
src.get(dst, off, len)has exactly the same effect as the loop
except that it first checks that there are sufficient bytes in this buffer and it is potentially much more efficient.for (int i = off; i < off + len; i++) dst[i] = src.get();- Parameters:
dst- The array into which bytes are to be writtenoffset- The offset within the array of the first byte to be written; must be non-negative and no larger thandst.lengthlength- The maximum number of bytes to be written to the given array; must be non-negative and no larger thandst.length - offset- Returns:
- This buffer
- Throws:
BufferUnderflowException- If there are fewer thanlengthbytes remaining in this bufferIndexOutOfBoundsException- If the preconditions on theoffsetandlengthparameters do not hold
-
get
Relative bulk get method.This method transfers bytes from this buffer into the given destination array. An invocation of this method of the form
src.get(a)behaves in exactly the same way as the invocationsrc.get(a, 0, a.length)
- Parameters:
dst- The destination array- Returns:
- This buffer
- Throws:
BufferUnderflowException- If there are fewer thanlengthbytes remaining in this buffer
-
asByteBuffer
Creates a view of this byte buffer as a byte buffer.The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer, and its byte order will be that of the byte buffer at the moment the view is created.
- Returns:
- A new byte buffer
-
toInputStream
InputStream toInputStream()Creates a newInputStreamwhich streams this buffer's content.The stream will start at this buffer's current position, and end at this buffer's limit.
- Returns:
- the new
InputStream
-
putShort
Relative put method for writing a short.Writes two bytes containing the given short value, in the current byte order, into this buffer at the current position, and then increments the position by two.
- Parameters:
value- The short value to be written- Returns:
- This buffer
- Throws:
BufferOverflowException- If there are fewer than two bytes remaining in this buffer
-
putShort
Absolute put method for writing a short.Writes two bytes containing the given short value, in the current byte order, into this buffer at the given index.
- Parameters:
index- The index at which the bytes will be writtenvalue- The short value to be written- Returns:
- This buffer
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit, minus one
-
putShort
Relative bulk put methodThis method transfers the entire content of the given source short array into this buffer.
- Parameters:
src- The source array- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer
-
putShort
Relative bulk put methodThis method transfers the shorts remaining in the given source buffer into this buffer. If there are more shorts remaining in the source buffer than in this buffer, that is, if
src.remaining()>remaining(), then no shorts are transferred and aBufferOverflowExceptionis thrown.Otherwise, this method copies n =
src.remaining()shorts from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.In other words, an invocation of this method of the form
dst.put(src)has exactly the same effect as the loopwhile (src.hasRemaining()) dst.put(src.get());except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. If this buffer and the source buffer share the same backing array or memory, then the result will be as if the source elements were first copied to an intermediate location before being written into this buffer.- Parameters:
src- The source buffer from which shorts are to be read; must not be this buffer- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer for the remaining shorts in the source buffer
-
getShort
short getShort()Relative get method for reading a short value.Reads the next two bytes at this buffer's current position, composing them into a short value according to the current byte order, and then increments the position by two.
- Returns:
- The short value at the buffer's current position
- Throws:
BufferUnderflowException- If there are fewer than two bytes remaining in this buffer
-
getShort
short getShort(long index) Absolute get method for reading a short value.Reads two bytes at the given index, composing them into a short value according to the current byte order.
- Parameters:
index- The index from which the bytes will be read- Returns:
- The short value at the given index
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit, minus one
-
asShortBuffer
Creates a view of this byte buffer as a short buffer.The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by two, and its byte order will be that of the byte buffer at the moment the view is created.
- Returns:
- A new short buffer
-
putInt
Relative put method for writing a int.Writes four bytes containing the given int value, in the current byte order, into this buffer at the current position, and then increments the position by four.
- Parameters:
value- The int value to be written- Returns:
- This buffer
- Throws:
BufferOverflowException- If there are fewer than four bytes remaining in this buffer
-
putInt
Absolute put method for writing a int.Writes four bytes containing the given int value, in the current byte order, into this buffer at the given index.
- Parameters:
index- The index at which the bytes will be writtenvalue- The int value to be written- Returns:
- This buffer
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit, minus one
-
putInt
Relative bulk put methodThis method transfers the entire content of the given source int array into this buffer.
- Parameters:
src- The source array- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer
-
putInt
Relative bulk put methodThis method transfers the ints remaining in the given source buffer into this buffer. If there are more ints remaining in the source buffer than in this buffer, that is, if
src.remaining()>remaining(), then no shorts are transferred and aBufferOverflowExceptionis thrown.Otherwise, this method copies n =
src.remaining()ints from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.In other words, an invocation of this method of the form
dst.put(src)has exactly the same effect as the loopwhile (src.hasRemaining()) dst.put(src.get());except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. If this buffer and the source buffer share the same backing array or memory, then the result will be as if the source elements were first copied to an intermediate location before being written into this buffer.- Parameters:
src- The source buffer from which ints are to be read; must not be this buffer- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer for the remaining ints in the source buffer
-
getInt
int getInt()Relative get method for reading a int value.Reads the next four bytes at this buffer's current position, composing them into a int value according to the current byte order, and then increments the position by four.
- Returns:
- The int value at the buffer's current position
- Throws:
BufferUnderflowException- If there are fewer than four bytes remaining in this buffer
-
getInt
int getInt(long index) Absolute get method for reading a int value.Reads four bytes at the given index, composing them into a int value according to the current byte order.
- Parameters:
index- The index from which the bytes will be read- Returns:
- The int value at the given index
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit, minus one
-
asIntBuffer
Creates a view of this byte buffer as a int buffer.The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by four, and its byte order will be that of the byte buffer at the moment the view is created.
- Returns:
- A new int buffer
-
putLong
Relative put method for writing a long.Writes eight bytes containing the given long value, in the current byte order, into this buffer at the current position, and then increments the position by eight.
- Parameters:
value- The long value to be written- Returns:
- This buffer
- Throws:
BufferOverflowException- If there are fewer than eight bytes remaining in this buffer
-
putLong
Absolute put method for writing a long.Writes eight bytes containing the given long value, in the current byte order, into this buffer at the given index.
- Parameters:
index- The index at which the bytes will be writtenvalue- The long value to be written- Returns:
- This buffer
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit, minus one
-
putLong
Relative bulk put methodThis method transfers the entire content of the given source long array into this buffer.
- Parameters:
src- The source array- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer
-
putLong
Relative bulk put methodThis method transfers the longs remaining in the given source buffer into this buffer. If there are more longs remaining in the source buffer than in this buffer, that is, if
src.remaining()>remaining(), then no shorts are transferred and aBufferOverflowExceptionis thrown.Otherwise, this method copies n =
src.remaining()longs from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.In other words, an invocation of this method of the form
dst.put(src)has exactly the same effect as the loopwhile (src.hasRemaining()) dst.put(src.get());except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. If this buffer and the source buffer share the same backing array or memory, then the result will be as if the source elements were first copied to an intermediate location before being written into this buffer.- Parameters:
src- The source buffer from which longs are to be read; must not be this buffer- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer for the remaining longs in the source buffer
-
getLong
long getLong()Relative get method for reading a long value.Reads the next eight bytes at this buffer's current position, composing them into a long value according to the current byte order, and then increments the position by eight.
- Returns:
- The long value at the buffer's current position
- Throws:
BufferUnderflowException- If there are fewer than eight bytes remaining in this buffer
-
getLong
long getLong(long index) Absolute get method for reading a long value.Reads eight bytes at the given index, composing them into a long value according to the current byte order.
- Parameters:
index- The index from which the bytes will be read- Returns:
- The long value at the given index
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit, minus one
-
asLongBuffer
Creates a view of this byte buffer as a long buffer.The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by eight, and its byte order will be that of the byte buffer at the moment the view is created.
- Returns:
- A new long buffer
-
putFloat
Relative put method for writing a float.Writes four bytes containing the given float value, in the current byte order, into this buffer at the current position, and then increments the position by four.
- Parameters:
value- The float value to be written- Returns:
- This buffer
- Throws:
BufferOverflowException- If there are fewer than four bytes remaining in this buffer
-
putFloat
Absolute put method for writing a float.Writes four bytes containing the given float value, in the current byte order, into this buffer at the given index.
- Parameters:
index- The index at which the bytes will be writtenvalue- The float value to be written- Returns:
- This buffer
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit, minus one
-
putFloat
Relative bulk put methodThis method transfers the entire content of the given source float array into this buffer.
- Parameters:
src- The source array- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer
-
putFloat
Relative bulk put methodThis method transfers the floats remaining in the given source buffer into this buffer. If there are more floats remaining in the source buffer than in this buffer, that is, if
src.remaining()>remaining(), then no shorts are transferred and aBufferOverflowExceptionis thrown.Otherwise, this method copies n =
src.remaining()floats from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.In other words, an invocation of this method of the form
dst.put(src)has exactly the same effect as the loopwhile (src.hasRemaining()) dst.put(src.get());except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. If this buffer and the source buffer share the same backing array or memory, then the result will be as if the source elements were first copied to an intermediate location before being written into this buffer.- Parameters:
src- The source buffer from which floats are to be read; must not be this buffer- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer for the remaining floats in the source buffer
-
getFloat
float getFloat()Relative get method for reading a float value.Reads the next four bytes at this buffer's current position, composing them into a float value according to the current byte order, and then increments the position by four.
- Returns:
- The float value at the buffer's current position
- Throws:
BufferUnderflowException- If there are fewer than four bytes remaining in this buffer
-
getFloat
float getFloat(long index) Absolute get method for reading a float value.Reads four bytes at the given index, composing them into a float value according to the current byte order.
- Parameters:
index- The index from which the bytes will be read- Returns:
- The float value at the given index
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit, minus one
-
asFloatBuffer
Creates a view of this byte buffer as a float buffer.The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by four, and its byte order will be that of the byte buffer at the moment the view is created.
- Returns:
- A new float buffer
-
putDouble
Relative put method for writing a double.Writes eight bytes containing the given double value, in the current byte order, into this buffer at the current position, and then increments the position by eight.
- Parameters:
value- The double value to be written- Returns:
- This buffer
- Throws:
BufferOverflowException- If there are fewer than eight bytes remaining in this buffer
-
putDouble
Absolute put method for writing a double.Writes eight bytes containing the given double value, in the current byte order, into this buffer at the given index.
- Parameters:
index- The index at which the bytes will be writtenvalue- The double value to be written- Returns:
- This buffer
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit, minus one
-
putDouble
Relative bulk put methodThis method transfers the entire content of the given source double array into this buffer.
- Parameters:
src- The source array- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer
-
putDouble
Relative bulk put methodThis method transfers the doubles remaining in the given source buffer into this buffer. If there are more doubles remaining in the source buffer than in this buffer, that is, if
src.remaining()>remaining(), then no shorts are transferred and aBufferOverflowExceptionis thrown.Otherwise, this method copies n =
src.remaining()doubles from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.In other words, an invocation of this method of the form
dst.put(src)has exactly the same effect as the loopwhile (src.hasRemaining()) dst.put(src.get());except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. If this buffer and the source buffer share the same backing array or memory, then the result will be as if the source elements were first copied to an intermediate location before being written into this buffer.- Parameters:
src- The source buffer from which doubles are to be read; must not be this buffer- Returns:
- This buffer
- Throws:
BufferOverflowException- If there is insufficient space in this buffer for the remaining doubles in the source buffer
-
getDouble
double getDouble()Relative get method for reading a double value.Reads the next eight bytes at this buffer's current position, composing them into a double value according to the current byte order, and then increments the position by eight.
- Returns:
- The double value at the buffer's current position
- Throws:
BufferUnderflowException- If there are fewer than eight bytes remaining in this buffer
-
getDouble
double getDouble(long index) Absolute get method for reading a double value.Reads eight bytes at the given index, composing them into a double value according to the current byte order.
- Parameters:
index- The index from which the bytes will be read- Returns:
- The double value at the given index
- Throws:
IndexOutOfBoundsException- Ifindexis negative or not smaller than the buffer's limit, minus one
-
asDoubleBuffer
Creates a view of this byte buffer as a double buffer.The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit values will be independent.
The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by eight, and its byte order will be that of the byte buffer at the moment the view is created.
- Returns:
- A new double buffer
-