Package com.mckoi.util
Class ByteBuffer
java.lang.Object
com.mckoi.util.ByteBuffer
A wrapper for an array of byte[]. This provides various functions for
altering the state of the buffer.
- Author:
- Tobias Downer
-
Constructor Summary
ConstructorsConstructorDescriptionByteBuffer
(byte[] buf) ByteBuffer
(byte[] buf, int offset, int length) Constructs the buffer. -
Method Summary
Modifier and TypeMethodDescriptionget
(byte[] b, int offset, int length) Gets a byte array from the buffer.byte
getByte()
int
getInt()
short
getShort()
int
limit()
Returns the limit of this buffer.int
position()
Returns the current position.void
position
(int position) Sets the position in to the buffer.put
(byte[] b) put
(byte[] b, int offset, int length) Puts a byte array into the buffer.put
(ByteBuffer buffer) Puts a ByteBuffer in to this buffer.putByte
(byte v) Puts/Gets a byte into the buffer at the current position.putInt
(int v) Puts/Gets an integer into the buffer at the current position.putShort
(short v) Puts/Gets a short into the buffer at the current position.
-
Constructor Details
-
ByteBuffer
public ByteBuffer(byte[] buf, int offset, int length) Constructs the buffer. -
ByteBuffer
public ByteBuffer(byte[] buf)
-
-
Method Details
-
position
public void position(int position) Sets the position in to the buffer. -
position
public int position()Returns the current position. -
limit
public int limit()Returns the limit of this buffer. -
put
Puts a byte array into the buffer. -
put
-
put
Puts a ByteBuffer in to this buffer. -
get
Gets a byte array from the buffer. -
putInt
Puts/Gets an integer into the buffer at the current position. -
getInt
public int getInt() -
putByte
Puts/Gets a byte into the buffer at the current position. -
getByte
public byte getByte() -
putShort
Puts/Gets a short into the buffer at the current position. -
getShort
public short getShort()
-