Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.nio

Class ByteBuffer

java.lang.Object
|
+--java.nio.Buffer
   |
   +--java.nio.ByteBuffer

All Implemented Interfaces:

Comparable


public abstract class ByteBuffer

extends Buffer

implements Comparable

Since:

Field Summary

byte[]backing_buffer

Method Summary

static java.nio.ByteBufferallocate(int capacity)

Allocates a new byte buffer.
static java.nio.ByteBufferallocateDirect(int capacity)

Allocates a new direct byte buffer.
byte[]array()

Returns the byte array that backs this buffer.
intarrayOffset()

Returns the offset within this buffer's backing array of the first element of the buffer
java.nio.CharBufferasCharBuffer()

Creates a view of this byte buffer as a char buffer.
java.nio.DoubleBufferasDoubleBuffer()

Creates a view of this byte buffer as a double buffer.
java.nio.FloatBufferasFloatBuffer()

Creates a view of this byte buffer as a float buffer.
java.nio.IntBufferasIntBuffer()

Creates a view of this byte buffer as an integer buffer.
java.nio.LongBufferasLongBuffer()

Creates a view of this byte buffer as a long buffer.
java.nio.ByteBufferasReadOnlyBuffer()

Creates a new, read-only byte buffer that shares this buffer's content.
java.nio.ShortBufferasShortBuffer()

Creates a view of this byte buffer as a short buffer.
java.nio.ByteBuffercompact()

Compacts this buffer.
intcompareTo(java.lang.Object obj)

Compares this buffer to another object.
java.nio.ByteBufferduplicate()

Creates a new byte buffer that shares this buffer's content.
booleanequals(java.lang.Object obj)

Tells whether or not this buffer is equal to another object.
java.nio.ByteBufferget(byte[] dst, int offset, int length)

This method transfers bytes from this buffer into the given destination array.
java.nio.ByteBufferget(byte[] dst)

This method transfers bytes from this buffer into the given destination array.
byteget()

Reads the byte at this buffer's current position, and then increments the position.
byteget(int index)

Absolute get method.
chargetChar()

Relative get method for reading a character value.
chargetChar(int index)

Absolute get method for reading a character value.
doublegetDouble()

Relative get method for reading a double value.
doublegetDouble(int index)

Absolute get method for reading a double value.
floatgetFloat()

Relative get method for reading a float value.
floatgetFloat(int index)

Absolute get method for reading a float value.
intgetInt()

Relative get method for reading an integer value.
intgetInt(int index)

Absolute get method for reading an integer value.
longgetLong()

Relative get method for reading a long value.
longgetLong(int index)

Absolute get method for reading a long value.
shortgetShort()

Relative get method for reading a short value.
shortgetShort(int index)

Absolute get method for reading a short value.
booleanhasArray()

Tells whether or not this buffer is backed by an accessible byte array.
inthashCode()

Returns the current hash code of this buffer.
booleanisDirect()

Tells whether or not this buffer is direct.
java.nio.ByteOrderorder()

Retrieves this buffer's byte order.
java.nio.ByteBufferorder(java.nio.ByteOrder endian)

Modifies this buffer's byte order.
java.nio.ByteBufferput(java.nio.ByteBuffer src)

Writes the content of src into the buffer.
java.nio.ByteBufferput(byte[] src, int offset, int length)

Writes the content of the the array src into the buffer.
java.nio.ByteBufferput(byte[] src)

Writes the content of the the array src into the buffer.
java.nio.ByteBufferput(byte b)

Relative put method.
java.nio.ByteBufferput(int index, byte b)

Absolute put method.
java.nio.ByteBufferputChar(char value)

Relative put method for writing a character value.
java.nio.ByteBufferputChar(int index, char value)

Absolute put method for writing a character value.
java.nio.ByteBufferputDouble(double value)

Relative put method for writing a double value.
java.nio.ByteBufferputDouble(int index, double value)

Absolute put method for writing a double value.
java.nio.ByteBufferputFloat(float value)

Relative put method for writing a float value.
java.nio.ByteBufferputFloat(int index, float value)

Relative put method for writing a float value.
java.nio.ByteBufferputInt(int value)

Relative put method for writing an integer value.
java.nio.ByteBufferputInt(int index, int value)

Absolute put method for writing an integer value.
java.nio.ByteBufferputLong(long value)

Relative put method for writing a long value.
java.nio.ByteBufferputLong(int index, long value)

Absolute put method for writing a float value.
java.nio.ByteBufferputShort(short value)

Relative put method for writing a short value.
java.nio.ByteBufferputShort(int index, short value)

Absolute put method for writing a short value.
java.nio.ByteBufferslice()

Creates a new byte buffer whose content is a shared subsequence of this buffer's content.
java.lang.StringtoString()

Returns a string summarizing the state of this buffer.
static java.nio.ByteBufferwrap(byte[] array, int offset, int length)

Wraps a byte array into a buffer.
static java.nio.ByteBufferwrap(byte[] array)

Wraps a byte array into a buffer.

Field Details

backing_buffer

protected byte[] backing_buffer


Method Details

allocate

public static ByteBuffer allocate(int capacity)

Allocates a new byte buffer.

Parameters:


allocateDirect

public static ByteBuffer allocateDirect(int capacity)

Allocates a new direct byte buffer.

Parameters:


array

public final byte[] array()

Returns the byte array that backs this buffer.

Throws:


arrayOffset

public final int arrayOffset()

Returns the offset within this buffer's backing array of the first element of the buffer

Throws:


asCharBuffer

public CharBuffer asCharBuffer()

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


asDoubleBuffer

public DoubleBuffer asDoubleBuffer()

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


asFloatBuffer

public FloatBuffer asFloatBuffer()

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


asIntBuffer

public IntBuffer asIntBuffer()

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


asLongBuffer

public LongBuffer asLongBuffer()

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


asReadOnlyBuffer

public ByteBuffer asReadOnlyBuffer()

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


asShortBuffer

public ShortBuffer asShortBuffer()

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


compact

public ByteBuffer compact()

Compacts this buffer.

Throws:


compareTo

public int compareTo(java.lang.Object obj)

Compares this buffer to another object.

Parameters:

Throws:


duplicate

public ByteBuffer duplicate()

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


equals

public boolean equals(java.lang.Object obj)

Tells whether or not this buffer is equal to another object.

Parameters:


get

public byte get()

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

Throws:


get

public ByteBuffer get(byte[] dst)

This method transfers bytes from this buffer into the given destination array.

Parameters:

Throws:


get

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

This method transfers bytes from this buffer into the given destination array.

Parameters:

Throws:


get

public byte get(int index)

Absolute get method.

Parameters:

Throws:


getChar

public char getChar()

Relative get method for reading a character value.

Throws:


getChar

public char getChar(int index)

Absolute get method for reading a character value.

Parameters:

Throws:


getDouble

public double getDouble()

Relative get method for reading a double value.

Throws:


getDouble

public double getDouble(int index)

Absolute get method for reading a double value.

Parameters:

Throws:


getFloat

public float getFloat()

Relative get method for reading a float value.

Throws:


getFloat

public float getFloat(int index)

Absolute get method for reading a float value.

Parameters:

Throws:


getInt

public int getInt()

Relative get method for reading an integer value.

Throws:


getInt

public int getInt(int index)

Absolute get method for reading an integer value.

Parameters:

Throws:


getLong

public long getLong()

Relative get method for reading a long value.

Throws:


getLong

public long getLong(int index)

Absolute get method for reading a long value.

Parameters:

Throws:


getShort

public short getShort()

Relative get method for reading a short value.

Throws:


getShort

public short getShort(int index)

Absolute get method for reading a short value.

Parameters:

Throws:


hasArray

public final boolean hasArray()

Tells whether or not this buffer is backed by an accessible byte array.


hashCode

public int hashCode()

Returns the current hash code of this buffer.


isDirect

public boolean isDirect()

Tells whether or not this buffer is direct.


order

public final ByteOrder order()

Retrieves this buffer's byte order.


order

public final ByteBuffer order(java.nio.ByteOrder endian)

Modifies this buffer's byte order.

Parameters:


put

public final ByteBuffer put(byte[] src)

Writes the content of the the array src into the buffer.

Parameters:

Throws:


put

public ByteBuffer put(byte b)

Relative put method.

Parameters:

Throws:


put

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

Writes the content of the the array src into the buffer.

Parameters:

Throws:


put

public ByteBuffer put(int index, byte b)

Absolute put method.

Parameters:

Throws:


put

public ByteBuffer put(java.nio.ByteBuffer src)

Writes the content of src into the buffer.

Parameters:

Throws:


putChar

public ByteBuffer putChar(char value)

Relative put method for writing a character value.

Parameters:

Throws:


putChar

public ByteBuffer putChar(int index, char value)

Absolute put method for writing a character value.

Parameters:

Throws:


putDouble

public ByteBuffer putDouble(double value)

Relative put method for writing a double value.

Parameters:

Throws:


putDouble

public ByteBuffer putDouble(int index, double value)

Absolute put method for writing a double value.

Parameters:

Throws:


putFloat

public ByteBuffer putFloat(float value)

Relative put method for writing a float value.

Parameters:

Throws:


putFloat

public ByteBuffer putFloat(int index, float value)

Relative put method for writing a float value.

Parameters:

Throws:


putInt

public ByteBuffer putInt(int value)

Relative put method for writing an integer value.

Parameters:

Throws:


putInt

public ByteBuffer putInt(int index, int value)

Absolute put method for writing an integer value.

Parameters:

Throws:


putLong

public ByteBuffer putLong(int index, long value)

Absolute put method for writing a float value.

Parameters:

Throws:


putLong

public ByteBuffer putLong(long value)

Relative put method for writing a long value.

Parameters:

Throws:


putShort

public ByteBuffer putShort(int index, short value)

Absolute put method for writing a short value.

Parameters:

Throws:


putShort

public ByteBuffer putShort(short value)

Relative put method for writing a short value.

Parameters:

Throws:


slice

public ByteBuffer slice()

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


toString

public String toString()

Returns a string summarizing the state of this buffer.


wrap

public static final ByteBuffer wrap(byte[] array)

Wraps a byte array into a buffer.

Parameters:


wrap

public static final ByteBuffer wrap(byte[] array, int offset, int length)

Wraps a byte array into a buffer.

Parameters:

Throws: