APIdia Launch Partner
Top Description Fields Constructors Methods
java.nio

pack-priv sealed Class HeapByteBuffer

extends ByteBuffer
permits HeapByteBufferR
Class Inheritance
Known Direct Subclasses
java.nio.HeapByteBufferR
Imports
java.lang.foreign.MemorySegment, jdk.internal.foreign.AbstractMemorySegmentImpl, .MemorySessionImpl, .SegmentFactories, jdk.internal.vm.annotation.ForceInline, java.util.Objects

A read/write HeapByteBuffer.

Field Summary

Modifier and TypeField and Description
private static final long
private static final long
Inherited from java.nio.ByteBuffer:
bigEndianhbisReadOnlynativeByteOrderoffset

Constructor Summary

AccessConstructor and Description
pack-priv
HeapByteBuffer(int cap, int lim, MemorySegment segment)

pack-priv
HeapByteBuffer(byte[] buf, int off, int len, MemorySegment segment)

protected
HeapByteBuffer(byte[] buf, int mark, int pos, int lim, int cap, int off, MemorySegment segment)

Method Summary

Modifier and TypeMethod and Description
pack-priv byte
_get(int i)

pack-priv void
_put(int i, byte b)

public CharBuffer
asCharBuffer()

Implements abstract java.nio.ByteBuffer.asCharBuffer.

Creates a view of this byte buffer as a char buffer.

public DoubleBuffer
asDoubleBuffer()

Implements abstract java.nio.ByteBuffer.asDoubleBuffer.

Creates a view of this byte buffer as a double buffer.

public FloatBuffer
asFloatBuffer()

Implements abstract java.nio.ByteBuffer.asFloatBuffer.

Creates a view of this byte buffer as a float buffer.

public IntBuffer
asIntBuffer()

Implements abstract java.nio.ByteBuffer.asIntBuffer.

Creates a view of this byte buffer as an int buffer.

public LongBuffer
asLongBuffer()

Implements abstract java.nio.ByteBuffer.asLongBuffer.

Creates a view of this byte buffer as a long buffer.

public ByteBuffer
asReadOnlyBuffer()

Implements abstract java.nio.ByteBuffer.asReadOnlyBuffer.

Creates a new, read-only byte buffer that shares this buffer's content.

public ShortBuffer
asShortBuffer()

Implements abstract java.nio.ByteBuffer.asShortBuffer.

Creates a view of this byte buffer as a short buffer.

private long
byteOffset(long i)

public ByteBuffer
compact()

Implements abstract java.nio.ByteBuffer.compact.

Compacts this buffer  (optional operation).

public ByteBuffer
duplicate()

Implements abstract java.nio.ByteBuffer.duplicate.

Creates a new byte buffer that shares this buffer's content.

public byte
get()

Implements abstract java.nio.ByteBuffer.get.

Relative get method.

public byte
get(int i)

Implements abstract java.nio.ByteBuffer.get.

Absolute get method.

public ByteBuffer
get(byte[] dst, int offset, int length)

Overrides java.nio.ByteBuffer.get.

Relative bulk get method.

public ByteBuffer
get(int index, byte[] dst, int offset, int length)

Overrides java.nio.ByteBuffer.get.

Absolute bulk get method.

public char
getChar()

Implements abstract java.nio.ByteBuffer.getChar.

Relative get method for reading a char value.

public char
getChar(int i)

Implements abstract java.nio.ByteBuffer.getChar.

Absolute get method for reading a char value.

public double
getDouble()

Implements abstract java.nio.ByteBuffer.getDouble.

Relative get method for reading a double value.

public double
getDouble(int i)

Implements abstract java.nio.ByteBuffer.getDouble.

Absolute get method for reading a double value.

public float
getFloat()

Implements abstract java.nio.ByteBuffer.getFloat.

Relative get method for reading a float value.

public float
getFloat(int i)

Implements abstract java.nio.ByteBuffer.getFloat.

Absolute get method for reading a float value.

public int
getInt()

Implements abstract java.nio.ByteBuffer.getInt.

Relative get method for reading an int value.

public int
getInt(int i)

Implements abstract java.nio.ByteBuffer.getInt.

Absolute get method for reading an int value.

public long
getLong()

Implements abstract java.nio.ByteBuffer.getLong.

Relative get method for reading a long value.

public long
getLong(int i)

Implements abstract java.nio.ByteBuffer.getLong.

Absolute get method for reading a long value.

public short
getShort()

Implements abstract java.nio.ByteBuffer.getShort.

Relative get method for reading a short value.

public short
getShort(int i)

Implements abstract java.nio.ByteBuffer.getShort.

Absolute get method for reading a short value.

pack-priv AbstractMemorySegmentImpl
heapSegment(Object base, long offset, long length, boolean readOnly, MemorySessionImpl bufferScope)

Implements abstract java.nio.Buffer.heapSegment.

public boolean
isDirect()

Implements abstract java.nio.ByteBuffer.isDirect.

Tells whether or not this byte buffer is direct.

public boolean
isReadOnly()

Implements abstract java.nio.Buffer.isReadOnly.

Tells whether or not this buffer is read-only.

protected int
ix(int i)

public ByteBuffer
put(byte x)

Implements abstract java.nio.ByteBuffer.put.

Relative put method  (optional operation).

public ByteBuffer
put(int i, byte x)

Implements abstract java.nio.ByteBuffer.put.

Absolute put method  (optional operation).

public ByteBuffer
put(byte[] src, int offset, int length)

Overrides java.nio.ByteBuffer.put.

Relative bulk put method  (optional operation).

public ByteBuffer
put(ByteBuffer src)

Overrides java.nio.ByteBuffer.put.

Relative bulk put method  (optional operation).

public ByteBuffer
put(int index, ByteBuffer src, int offset, int length)

Overrides java.nio.ByteBuffer.put.

Absolute bulk put method  (optional operation).

public ByteBuffer
put(int index, byte[] src, int offset, int length)

Overrides java.nio.ByteBuffer.put.

Absolute bulk put method  (optional operation).

public ByteBuffer
putChar(char x)

Implements abstract java.nio.ByteBuffer.putChar.

Relative put method for writing a char value  (optional operation).

public ByteBuffer
putChar(int i, char x)

Implements abstract java.nio.ByteBuffer.putChar.

Absolute put method for writing a char value  (optional operation).

public ByteBuffer
putDouble(double x)

Implements abstract java.nio.ByteBuffer.putDouble.

Relative put method for writing a double value  (optional operation).

public ByteBuffer
putDouble(int i, double x)

Implements abstract java.nio.ByteBuffer.putDouble.

Absolute put method for writing a double value  (optional operation).

public ByteBuffer
putFloat(float x)

Implements abstract java.nio.ByteBuffer.putFloat.

Relative put method for writing a float value  (optional operation).

public ByteBuffer
putFloat(int i, float x)

Implements abstract java.nio.ByteBuffer.putFloat.

Absolute put method for writing a float value  (optional operation).

public ByteBuffer
putInt(int x)

Implements abstract java.nio.ByteBuffer.putInt.

Relative put method for writing an int value  (optional operation).

public ByteBuffer
putInt(int i, int x)

Implements abstract java.nio.ByteBuffer.putInt.

Absolute put method for writing an int value  (optional operation).

public ByteBuffer
putLong(long x)

Implements abstract java.nio.ByteBuffer.putLong.

Relative put method for writing a long value  (optional operation).

public ByteBuffer
putLong(int i, long x)

Implements abstract java.nio.ByteBuffer.putLong.

Absolute put method for writing a long value  (optional operation).

public ByteBuffer
putShort(short x)

Implements abstract java.nio.ByteBuffer.putShort.

Relative put method for writing a short value  (optional operation).

public ByteBuffer
putShort(int i, short x)

Implements abstract java.nio.ByteBuffer.putShort.

Absolute put method for writing a short value  (optional operation).

pack-priv int
scaleShifts()

Implements abstract java.nio.Buffer.scaleShifts.

Returns the scale shifts for this Buffer.

public ByteBuffer
slice()

Implements abstract java.nio.ByteBuffer.slice.

Creates a new byte buffer whose content is a shared subsequence of this buffer's content.

public ByteBuffer
slice(int index, int length)

Implements abstract java.nio.ByteBuffer.slice.

Creates a new byte buffer whose content is a shared subsequence of this buffer's content.

Inherited from java.nio.ByteBuffer:
alignedSlicealignmentOffsetallocateallocateDirectarrayarrayOffsetbaseclearcompareToequalsflipgetgetgetArrayhasArrayhashCodelimitmarkmismatchorderorderpositionputputputArrayputBufferresetrewindtoStringwrapwrap

Field Detail

ARRAY_BASE_OFFSETback to summary
private static final long ARRAY_BASE_OFFSET

Hides java.nio.ByteBuffer.ARRAY_BASE_OFFSET.

ARRAY_INDEX_SCALEback to summary
private static final long ARRAY_INDEX_SCALE

Constructor Detail

HeapByteBufferback to summary
pack-priv HeapByteBuffer(int cap, int lim, MemorySegment segment)
HeapByteBufferback to summary
pack-priv HeapByteBuffer(byte[] buf, int off, int len, MemorySegment segment)
HeapByteBufferback to summary
protected HeapByteBuffer(byte[] buf, int mark, int pos, int lim, int cap, int off, MemorySegment segment)

Method Detail

_getback to summary
pack-priv byte _get(int i)
_putback to summary
pack-priv void _put(int i, byte b)
asCharBufferback to summary
public CharBuffer asCharBuffer()

Implements abstract java.nio.ByteBuffer.asCharBuffer.

Doc from java.nio.ByteBuffer.asCharBuffer.

Creates a view of this byte buffer as a char 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, limit, and mark 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, its mark will be undefined, and its byte order will be that of the byte buffer at the moment the view is created. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

asDoubleBufferback to summary
public DoubleBuffer asDoubleBuffer()

Implements abstract java.nio.ByteBuffer.asDoubleBuffer.

Doc from java.nio.ByteBuffer.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, limit, and mark 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, its mark will be undefined, and its byte order will be that of the byte buffer at the moment the view is created. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

asFloatBufferback to summary
public FloatBuffer asFloatBuffer()

Implements abstract java.nio.ByteBuffer.asFloatBuffer.

Doc from java.nio.ByteBuffer.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, limit, and mark 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, its mark will be undefined, and its byte order will be that of the byte buffer at the moment the view is created. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

asIntBufferback to summary
public IntBuffer asIntBuffer()

Implements abstract java.nio.ByteBuffer.asIntBuffer.

Doc from java.nio.ByteBuffer.asIntBuffer.

Creates a view of this byte buffer as an 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, limit, and mark 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, its mark will be undefined, and its byte order will be that of the byte buffer at the moment the view is created. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

asLongBufferback to summary
public LongBuffer asLongBuffer()

Implements abstract java.nio.ByteBuffer.asLongBuffer.

Doc from java.nio.ByteBuffer.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, limit, and mark 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, its mark will be undefined, and its byte order will be that of the byte buffer at the moment the view is created. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

asReadOnlyBufferback to summary
public ByteBuffer asReadOnlyBuffer()

Implements abstract java.nio.ByteBuffer.asReadOnlyBuffer.

Doc from java.nio.ByteBuffer.asReadOnlyBuffer.

Creates a new, read-only 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; the new buffer itself, however, will be read-only and will not allow the shared content to be modified. The two buffers' position, limit, and mark values will be independent.

The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer, and its byte order will be BIG_ENDIAN.

If this buffer is itself read-only then this method behaves in exactly the same way as the duplicate method.

asShortBufferback to summary
public ShortBuffer asShortBuffer()

Implements abstract java.nio.ByteBuffer.asShortBuffer.

Doc from java.nio.ByteBuffer.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, limit, and mark 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, its mark will be undefined, and its byte order will be that of the byte buffer at the moment the view is created. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

byteOffsetback to summary
private long byteOffset(long i)
compactback to summary
public ByteBuffer compact()

Implements abstract java.nio.ByteBuffer.compact.

Doc from java.nio.ByteBuffer.compact.

Compacts this buffer  (optional operation).

The bytes between the buffer's current position and its limit, if any, are copied to the beginning of the buffer. That is, the byte at index p = position() is copied to index zero, the byte at index p + 1 is copied to index one, and so forth until the byte at index limit() - 1 is copied to index n = limit() - 1 - p. The buffer's position is then set to n+1 and its limit is set to its capacity. The mark, if defined, is discarded.

The buffer's position is set to the number of bytes copied, rather than to zero, so that an invocation of this method can be followed immediately by an invocation of another relative put method.

Invoke this method after writing data from a buffer in case the write was incomplete. The following loop, for example, copies bytes from one channel to another via the buffer buf:

buf.clear(); // Prepare buffer for use while (in.read(buf) >= 0 || buf.position != 0) { buf.flip(); out.write(buf); buf.compact(); // In case of partial write }
buf.clear();          // Prepare buffer for use
while (in.read(buf) >= 0 || buf.position != 0) {
    buf.flip();
    out.write(buf);
    buf.compact();    // In case of partial write
}
duplicateback to summary
public ByteBuffer duplicate()

Implements abstract java.nio.ByteBuffer.duplicate.

Doc from java.nio.ByteBuffer.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, limit, and mark values will be independent.

The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer, and its byte order will be BIG_ENDIAN. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

getback to summary
public byte get()

Implements abstract java.nio.ByteBuffer.get.

Doc from java.nio.ByteBuffer.get.

Relative get method. Reads the byte at this buffer's current position, and then increments the position.

getback to summary
public byte get(int i)

Implements abstract java.nio.ByteBuffer.get.

Doc from java.nio.ByteBuffer.get.

Absolute get method. Reads the byte at the given index.

getback to summary
public ByteBuffer get(byte[] dst, int offset, int length)

Overrides java.nio.ByteBuffer.get.

Doc from java.nio.ByteBuffer.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 a BufferUnderflowException is thrown.

Otherwise, this method copies length bytes 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 by length.

In other words, an invocation of this method of the form src.get(dst, off, len) has exactly the same effect as the loop

for (int i = off; i < off + len; i++) dst[i] = src.get();
for (int i = off; i < off + len; i++)
    dst[i] = src.get();
except that it first checks that there are sufficient bytes in this buffer and it is potentially much more efficient.
getback to summary
public ByteBuffer get(int index, byte[] dst, int offset, int length)

Overrides java.nio.ByteBuffer.get.

Doc from java.nio.ByteBuffer.get.

Absolute bulk get method.

This method transfers length bytes from this buffer into the given array, starting at the given index in this buffer and at the given offset in the array. The position of this buffer is unchanged.

An invocation of this method of the form src.get(index, dst, offset, length) has exactly the same effect as the following loop except that it first checks the consistency of the supplied parameters and it is potentially much more efficient:

for (int i = offset, j = index; i < offset + length; i++, j++) dst[i] = src.get(j);
for (int i = offset, j = index; i < offset + length; i++, j++)
    dst[i] = src.get(j);
getCharback to summary
public char getChar()

Implements abstract java.nio.ByteBuffer.getChar.

Doc from java.nio.ByteBuffer.getChar.

Relative get method for reading a char value.

Reads the next two bytes at this buffer's current position, composing them into a char value according to the current byte order, and then increments the position by two.

getCharback to summary
public char getChar(int i)

Implements abstract java.nio.ByteBuffer.getChar.

Doc from java.nio.ByteBuffer.getChar.

Absolute get method for reading a char value.

Reads two bytes at the given index, composing them into a char value according to the current byte order.

getDoubleback to summary
public double getDouble()

Implements abstract java.nio.ByteBuffer.getDouble.

Doc from java.nio.ByteBuffer.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.

getDoubleback to summary
public double getDouble(int i)

Implements abstract java.nio.ByteBuffer.getDouble.

Doc from java.nio.ByteBuffer.getDouble.

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.

getFloatback to summary
public float getFloat()

Implements abstract java.nio.ByteBuffer.getFloat.

Doc from java.nio.ByteBuffer.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.

getFloatback to summary
public float getFloat(int i)

Implements abstract java.nio.ByteBuffer.getFloat.

Doc from java.nio.ByteBuffer.getFloat.

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.

getIntback to summary
public int getInt()

Implements abstract java.nio.ByteBuffer.getInt.

Doc from java.nio.ByteBuffer.getInt.

Relative get method for reading an int value.

Reads the next four bytes at this buffer's current position, composing them into an int value according to the current byte order, and then increments the position by four.

getIntback to summary
public int getInt(int i)

Implements abstract java.nio.ByteBuffer.getInt.

Doc from java.nio.ByteBuffer.getInt.

Absolute get method for reading an int value.

Reads four bytes at the given index, composing them into a int value according to the current byte order.

getLongback to summary
public long getLong()

Implements abstract java.nio.ByteBuffer.getLong.

Doc from java.nio.ByteBuffer.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.

getLongback to summary
public long getLong(int i)

Implements abstract java.nio.ByteBuffer.getLong.

Doc from java.nio.ByteBuffer.getLong.

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.

getShortback to summary
public short getShort()

Implements abstract java.nio.ByteBuffer.getShort.

Doc from java.nio.ByteBuffer.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.

getShortback to summary
public short getShort(int i)

Implements abstract java.nio.ByteBuffer.getShort.

Doc from java.nio.ByteBuffer.getShort.

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.

heapSegmentback to summary
pack-priv AbstractMemorySegmentImpl heapSegment(Object base, long offset, long length, boolean readOnly, MemorySessionImpl bufferScope)

Implements abstract java.nio.Buffer.heapSegment.

Annotations
@ForceInline
@Override
isDirectback to summary
public boolean isDirect()

Implements abstract java.nio.ByteBuffer.isDirect.

Doc from java.nio.ByteBuffer.isDirect.

Tells whether or not this byte buffer is direct.

isReadOnlyback to summary
public boolean isReadOnly()

Implements abstract java.nio.Buffer.isReadOnly.

Doc from java.nio.Buffer.isReadOnly.

Tells whether or not this buffer is read-only.

ixback to summary
protected int ix(int i)
putback to summary
public ByteBuffer put(byte x)

Implements abstract java.nio.ByteBuffer.put.

Doc from java.nio.ByteBuffer.put.

Relative put method  (optional operation).

Writes the given byte into this buffer at the current position, and then increments the position.

putback to summary
public ByteBuffer put(int i, byte x)

Implements abstract java.nio.ByteBuffer.put.

Doc from java.nio.ByteBuffer.put.

Absolute put method  (optional operation).

Writes the given byte into this buffer at the given index.

putback to summary
public ByteBuffer put(byte[] src, int offset, int length)

Overrides java.nio.ByteBuffer.put.

Doc from java.nio.ByteBuffer.put.

Relative bulk put method  (optional operation).

This method transfers bytes into this buffer from the given source array. If there are more bytes to be copied from the array than remain in this buffer, that is, if length > remaining(), then no bytes are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies length bytes from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length.

In other words, an invocation of this method of the form dst.put(src, off, len) has exactly the same effect as the loop

for (int i = off; i < off + len; i++) dst.put(src[i]);
for (int i = off; i < off + len; i++)
    dst.put(src[i]);
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.
putback to summary
public ByteBuffer put(ByteBuffer src)

Overrides java.nio.ByteBuffer.put.

Doc from java.nio.ByteBuffer.put.

Relative bulk put method  (optional operation).

This 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 a BufferOverflowException is 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 loop

while (src.hasRemaining()) dst.put(src.get());
while (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.
putback to summary
public ByteBuffer put(int index, ByteBuffer src, int offset, int length)

Overrides java.nio.ByteBuffer.put.

Doc from java.nio.ByteBuffer.put.

Absolute bulk put method  (optional operation).

This method transfers length bytes into this buffer from the given source buffer, starting at the given offset in the source buffer and the given index in 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

for (int i = offset, j = index; i < offset + length; i++, j++) dst.put(j, src.get(i));
for (int i = offset, j = index; i < offset + length; i++, j++)
    dst.put(j, src.get(i));
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.
putback to summary
public ByteBuffer put(int index, byte[] src, int offset, int length)

Overrides java.nio.ByteBuffer.put.

Doc from java.nio.ByteBuffer.put.

Absolute bulk put method  (optional operation).

This method transfers length bytes from the given array, starting at the given offset in the array and at the given index in this buffer. The position of this buffer is unchanged.

An invocation of this method of the form dst.put(index, src, offset, length) has exactly the same effect as the following loop except that it first checks the consistency of the supplied parameters and it is potentially much more efficient:

for (int i = offset, j = index; i < offset + length; i++, j++) dst.put(j, src[i]);
for (int i = offset, j = index; i < offset + length; i++, j++)
    dst.put(j, src[i]);
putCharback to summary
public ByteBuffer putChar(char x)

Implements abstract java.nio.ByteBuffer.putChar.

Doc from java.nio.ByteBuffer.putChar.

Relative put method for writing a char value  (optional operation).

Writes two bytes containing the given char value, in the current byte order, into this buffer at the current position, and then increments the position by two.

putCharback to summary
public ByteBuffer putChar(int i, char x)

Implements abstract java.nio.ByteBuffer.putChar.

Doc from java.nio.ByteBuffer.putChar.

Absolute put method for writing a char value  (optional operation).

Writes two bytes containing the given char value, in the current byte order, into this buffer at the given index.

putDoubleback to summary
public ByteBuffer putDouble(double x)

Implements abstract java.nio.ByteBuffer.putDouble.

Doc from java.nio.ByteBuffer.putDouble.

Relative put method for writing a double value  (optional operation).

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.

putDoubleback to summary
public ByteBuffer putDouble(int i, double x)

Implements abstract java.nio.ByteBuffer.putDouble.

Doc from java.nio.ByteBuffer.putDouble.

Absolute put method for writing a double value  (optional operation).

Writes eight bytes containing the given double value, in the current byte order, into this buffer at the given index.

putFloatback to summary
public ByteBuffer putFloat(float x)

Implements abstract java.nio.ByteBuffer.putFloat.

Doc from java.nio.ByteBuffer.putFloat.

Relative put method for writing a float value  (optional operation).

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.

putFloatback to summary
public ByteBuffer putFloat(int i, float x)

Implements abstract java.nio.ByteBuffer.putFloat.

Doc from java.nio.ByteBuffer.putFloat.

Absolute put method for writing a float value  (optional operation).

Writes four bytes containing the given float value, in the current byte order, into this buffer at the given index.

putIntback to summary
public ByteBuffer putInt(int x)

Implements abstract java.nio.ByteBuffer.putInt.

Doc from java.nio.ByteBuffer.putInt.

Relative put method for writing an int value  (optional operation).

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.

putIntback to summary
public ByteBuffer putInt(int i, int x)

Implements abstract java.nio.ByteBuffer.putInt.

Doc from java.nio.ByteBuffer.putInt.

Absolute put method for writing an int value  (optional operation).

Writes four bytes containing the given int value, in the current byte order, into this buffer at the given index.

putLongback to summary
public ByteBuffer putLong(long x)

Implements abstract java.nio.ByteBuffer.putLong.

Doc from java.nio.ByteBuffer.putLong.

Relative put method for writing a long value  (optional operation).

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.

putLongback to summary
public ByteBuffer putLong(int i, long x)

Implements abstract java.nio.ByteBuffer.putLong.

Doc from java.nio.ByteBuffer.putLong.

Absolute put method for writing a long value  (optional operation).

Writes eight bytes containing the given long value, in the current byte order, into this buffer at the given index.

putShortback to summary
public ByteBuffer putShort(short x)

Implements abstract java.nio.ByteBuffer.putShort.

Doc from java.nio.ByteBuffer.putShort.

Relative put method for writing a short value  (optional operation).

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.

putShortback to summary
public ByteBuffer putShort(int i, short x)

Implements abstract java.nio.ByteBuffer.putShort.

Doc from java.nio.ByteBuffer.putShort.

Absolute put method for writing a short value  (optional operation).

Writes two bytes containing the given short value, in the current byte order, into this buffer at the given index.

scaleShiftsback to summary
pack-priv int scaleShifts()

Implements abstract java.nio.Buffer.scaleShifts.

Doc from java.nio.Buffer.scaleShifts.

Returns the scale shifts for this Buffer.

The scale shifts are: ByteBuffer: 0 ShortBuffer, CharBuffer: 1 IntBuffer, FloatBuffer: 2 LongBuffer, DoubleBuffer: 3

Annotations
@ForceInline
@Override
sliceback to summary
public ByteBuffer slice()

Implements abstract java.nio.ByteBuffer.slice.

Doc from java.nio.ByteBuffer.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, limit, and mark 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, its mark will be undefined, and its byte order will be BIG_ENDIAN. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

sliceback to summary
public ByteBuffer slice(int index, int length)

Implements abstract java.nio.ByteBuffer.slice.

Doc from java.nio.ByteBuffer.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 position index in this buffer, and will contain length elements. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position, limit, and mark values will be independent.

The new buffer's position will be zero, its capacity and its limit will be length, its mark will be undefined, and its byte order will be BIG_ENDIAN. The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.

Annotations
@Override