GeezerVison is showing docs.oracle.com — ByteBuffer (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
- Summary:
- Nested |
- Field |
- Constr |
- Method
- Detail:
- Field |
- Constr |
- Method
compact1, compact2, compact3
java.nio
Class ByteBuffer
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
| Modifier and Type |
Method |
Description |
static ByteBuffer |
allocate(int capacity) |
Allocates a new byte buffer.
|
static ByteBuffer |
allocateDirect(int capacity) |
Allocates a new direct byte buffer.
|
byte[] |
array() |
Returns the byte array that backs this
buffer (optional operation).
|
int |
arrayOffset() |
Returns the offset within this buffer's backing array of the first
element of the buffer (optional operation).
|
abstract CharBuffer |
asCharBuffer() |
Creates a view of this byte buffer as a char buffer.
|
abstract DoubleBuffer |
asDoubleBuffer() |
Creates a view of this byte buffer as a double buffer.
|
abstract FloatBuffer |
asFloatBuffer() |
Creates a view of this byte buffer as a float buffer.
|
abstract IntBuffer |
asIntBuffer() |
Creates a view of this byte buffer as an int buffer.
|
abstract LongBuffer |
asLongBuffer() |
Creates a view of this byte buffer as a long buffer.
|
abstract ByteBuffer |
asReadOnlyBuffer() |
Creates a new, read-only byte buffer that shares this buffer's
content.
|
abstract ShortBuffer |
asShortBuffer() |
Creates a view of this byte buffer as a short buffer.
|
abstract ByteBuffer |
compact() |
Compacts this buffer (optional operation).
|
int |
compareTo(ByteBuffer that) |
Compares this buffer to another.
|
abstract ByteBuffer |
duplicate() |
Creates a new byte buffer that shares this buffer's content.
|
boolean |
equals(Object ob) |
Tells whether or not this buffer is equal to another object.
|
abstract byte |
get() |
Relative get method.
|
ByteBuffer |
get(byte[] dst) |
Relative bulk get method.
|
ByteBuffer |
get(byte[] dst,
int offset,
int length) |
Relative bulk get method.
|
abstract byte |
get(int index) |
Absolute get method.
|
abstract char |
getChar() |
Relative get method for reading a char value.
|
abstract char |
getChar(int index) |
Absolute get method for reading a char value.
|
abstract double |
getDouble() |
Relative get method for reading a double value.
|
abstract double |
getDouble(int index) |
Absolute get method for reading a double value.
|
abstract float |
getFloat() |
Relative get method for reading a float value.
|
abstract float |
getFloat(int index) |
Absolute get method for reading a float value.
|
abstract int |
getInt() |
Relative get method for reading an int value.
|
abstract int |
getInt(int index) |
Absolute get method for reading an int value.
|
abstract long |
getLong() |
Relative get method for reading a long value.
|
abstract long |
getLong(int index) |
Absolute get method for reading a long value.
|
abstract short |
getShort() |
Relative get method for reading a short value.
|
abstract short |
getShort(int index) |
Absolute get method for reading a short value.
|
boolean |
hasArray() |
Tells whether or not this buffer is backed by an accessible byte
array.
|
int |
hashCode() |
Returns the current hash code of this buffer.
|
abstract boolean |
isDirect() |
Tells whether or not this byte buffer is direct.
|
ByteOrder |
order() |
Retrieves this buffer's byte order.
|
ByteBuffer |
order(ByteOrder bo) |
Modifies this buffer's byte order.
|
abstract ByteBuffer |
put(byte b) |
Relative put method (optional operation).
|
ByteBuffer |
put(byte[] src) |
Relative bulk put method (optional operation).
|
ByteBuffer |
put(byte[] src,
int offset,
int length) |
Relative bulk put method (optional operation).
|
ByteBuffer |
put(ByteBuffer src) |
Relative bulk put method (optional operation).
|
abstract ByteBuffer |
put(int index,
byte b) |
Absolute put method (optional operation).
|
abstract ByteBuffer |
putChar(char value) |
Relative put method for writing a char
value (optional operation).
|
abstract ByteBuffer |
putChar(int index,
char value) |
Absolute put method for writing a char
value (optional operation).
|
abstract ByteBuffer |
putDouble(double value) |
Relative put method for writing a double
value (optional operation).
|
abstract ByteBuffer |
putDouble(int index,
double value) |
Absolute put method for writing a double
value (optional operation).
|
abstract ByteBuffer |
putFloat(float value) |
Relative put method for writing a float
value (optional operation).
|
abstract ByteBuffer |
putFloat(int index,
float value) |
Absolute put method for writing a float
value (optional operation).
|
abstract ByteBuffer |
putInt(int value) |
Relative put method for writing an int
value (optional operation).
|
abstract ByteBuffer |
putInt(int index,
int value) |
Absolute put method for writing an int
value (optional operation).
|
abstract ByteBuffer |
putLong(int index,
long value) |
Absolute put method for writing a long
value (optional operation).
|
abstract ByteBuffer |
putLong(long value) |
Relative put method for writing a long
value (optional operation).
|
abstract ByteBuffer |
putShort(int index,
short value) |
Absolute put method for writing a short
value (optional operation).
|
abstract ByteBuffer |
putShort(short value) |
Relative put method for writing a short
value (optional operation).
|
abstract ByteBuffer |
slice() |
Creates a new byte buffer whose content is a shared subsequence of
this buffer's content.
|
String |
toString() |
Returns a string summarizing the state of this buffer.
|
static ByteBuffer |
wrap(byte[] array) |
Wraps a byte array into a buffer.
|
static ByteBuffer |
wrap(byte[] array,
int offset,
int length) |
Wraps a byte array into a buffer.
|
-
Methods inherited from class java.nio.Buffer
capacity, clear, flip, hasRemaining, isReadOnly, limit, limit, mark, position, position, remaining, reset, rewind
-
-
Method Detail
-
get
public abstract 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
-
hashCode
public int hashCode()
Returns the current hash code of this buffer.
The hash code of a byte buffer depends only upon its remaining
elements; that is, upon the elements from position() up to, and
including, the element at limit() - 1.
Because buffer hash codes are content-dependent, it is inadvisable
to use buffers as keys in hash maps or similar data structures unless it
is known that their contents will not change.
- Overrides:
hashCode in class Object
- Returns:
- The current hash code of this buffer
- See Also:
Object.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)
Java™ Platform Standard Ed. 8
- Summary:
- Nested |
- Field |
- Constr |
- Method
- Detail:
- Field |
- Constr |
- Method
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|