put
Relative put: writes the char at current position and increments position.
Writes length characters from src (starting at srcOffset) into this buffer, advancing the position.
Relative bulk put method (optional operation).
This method transfers the chars remaining in the given source buffer into this buffer. If there are more chars remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no chars are transferred and a [ ] is thrown.
Otherwise, this method copies n = src.remaining() chars 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
{@snippet lang=java :
while (src.hasRemaining())Content copied to clipboarddst.put(src.get());Content copied to clipboard}
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.
Return
This buffer
Parameters
The source buffer from which chars are to be read; must not be this buffer
Throws
If there is insufficient space in this buffer for the remaining chars in the source buffer
If the source buffer is this buffer
If this buffer is read-only
Relative bulk put method (optional operation).
This method transfers the entire content of the given source string into this buffer. An invocation of this method of the form dst.put(s) behaves in exactly the same way as the invocation
{@snippet lang=java :
dst.put(s, 0, s.length())Content copied to clipboard}
Return
This buffer
Parameters
The source string
Throws
If there is insufficient space in this buffer
If this buffer is read-only
Relative bulk put method (optional operation).
This method transfers chars from the given string into this buffer. If there are more chars to be copied from the string than remain in this buffer, that is, if end - start > remaining(), then no chars are transferred and a [ ] is thrown.
Otherwise, this method copies n = end - start chars from the given string into this buffer, starting at the given start index and at the current position of this buffer. The position of this buffer is then incremented by n.
In other words, an invocation of this method of the form dst.put(src, start, end) has exactly the same effect as the loop
{@snippet lang=java :
for (int i = start; i < end; i++)Content copied to clipboarddst.put(src.charAt(i));Content copied to clipboard}
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.
Return
This buffer
Parameters
The string from which chars are to be read
The offset within the string of the first char to be read; must be non-negative and no larger than string.length()
The offset within the string of the last char to be read, plus one; must be non-negative and no larger than string.length()
Throws
If there is insufficient space in this buffer
If the preconditions on the start and end parameters do not hold
If this buffer is read-only