java.lang.Object | |
↳ | java.nio.Buffer |
Known Direct Subclasses |
Known Indirect Subclasses |
A buffer is a list of elements of a specific primitive type.
A buffer can be described by the following properties:
limit - 1
. Accessing
elements out of the scope will cause an exception. Limit may not be negative
and not greater than capacity.ReadOnlyBufferException
,
while changing the position, limit and mark of a read-only buffer is OK.Buffers are not thread-safe. If concurrent access to a buffer instance is required, then the callers are responsible to take care of the synchronization issues.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the capacity of this buffer.
| |||||||||||
Clears this buffer.
| |||||||||||
Flips this buffer.
| |||||||||||
Indicates if there are elements remaining in this buffer, that is if
position < limit . | |||||||||||
Indicates whether this buffer is read-only.
| |||||||||||
Returns the limit of this buffer.
| |||||||||||
Sets the limit of this buffer.
| |||||||||||
Marks the current position, so that the position may return to this point
later by calling
reset() . | |||||||||||
Returns the position of this buffer.
| |||||||||||
Sets the position of this buffer.
| |||||||||||
Returns the number of remaining elements in this buffer, that is
limit - position . | |||||||||||
Resets the position of this buffer to the
mark . | |||||||||||
Rewinds this buffer.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
Returns the capacity of this buffer.
Clears this buffer.
While the content of this buffer is not changed, the following internal changes take place: the current position is reset back to the start of the buffer, the value of the buffer limit is made equal to the capacity and mark is cleared.
Flips this buffer.
The limit is set to the current position, then the position is set to zero, and the mark is cleared.
The content of this buffer is not changed.
Indicates if there are elements remaining in this buffer, that is if
position < limit
.
true
if there are elements remaining in this buffer,
false
otherwise.Indicates whether this buffer is read-only.
true
if this buffer is read-only, false
otherwise.Returns the limit of this buffer.
Sets the limit of this buffer.
If the current position in the buffer is in excess of
newLimit
then, on returning from this call, it will have
been adjusted to be equivalent to newLimit
. If the mark
is set and is greater than the new limit, then it is cleared.
newLimit | the new limit, must not be negative and not greater than capacity. |
---|
IllegalArgumentException | if newLimit is invalid. |
---|
Marks the current position, so that the position may return to this point
later by calling reset()
.
Returns the position of this buffer.
Sets the position of this buffer.
If the mark is set and it is greater than the new position, then it is cleared.
newPosition | the new position, must be not negative and not greater than limit. |
---|
IllegalArgumentException | if newPosition is invalid. |
---|
Returns the number of remaining elements in this buffer, that is
limit - position
.
Resets the position of this buffer to the mark
.
InvalidMarkException | if the mark is not set. |
---|
Rewinds this buffer.
The position is set to zero, and the mark is cleared. The content of this buffer is not changed.