java-bytearray
README
ByteArray class, MIT (c) 2018-2021 miktim@mail.ru
Relative put/get data into/from auto expandable byte array (big-endian order). Data types: byte, byte[], short, int, long, float, double. Float and double values are converted to IEEE 754 int/long.
package org.miktim
Overview:
Class ByteArray
Constructors:
ByteArray();
// buffer length = AUTOEXPAND_INCREMENT, data length = 0, pointer = 0, resizeable
ByteArray(int bytes);
// buffer length = bytes, data length = 0, pointer = 0, not resizeable
ByteArray(byte[] bytes);
// buffer = bytes[], data length = bytes.length, pointer = 0, not resizeable
Constants:
static final int AUTOEXPAND_INCREMENT = 64;
Methods:
int length(); // returns data length
int getPointer(); // returns current pointer (offset)
void setPointer(int pointer) throws ArrayIndexOutOfBoundsException;
// pointer between 0 and data length
byte[] array(); // returns data array
//! if data length = buffer length, buffer returned
int truncate() throws IllegalStateException; // truncate data to the current pointer
void enableResizing(boolean yesNo); // enable/disable autoexpand/truncate
boolean isResizable();
// PUT data methods. All methods returns а new pointer (offset).
// Can throw an ArrayIndexOutOfBoundsException (resizing disabled)
int put(byte b);
int put(byte[] bytes);
int putShort(short s);
int putInt(int i);
int putFloat(float f);
int putLong(long i);
int putDouble(double d);
// GET data methods
// Can throw an ArrayIndexOutOfBoundsException
byte get();
byte[] get(int len);
short getShort();
int getInt();
float getFloat();
long getLong();
double getDouble();
Описание
Relative put/get data into/from byte array. Data types: byte[], byte, short, int, long, float, double
Языки
Java