/
java-bytearray

java-bytearray

Публичный
0
M
miktim
29 авг 2026, 07:59
5 дней назад
5 дней назад
5 дней назад
5 дней назад
5 дней назад
5 дней назад
README
ByteArray class, MIT (c) 2018-2026 miktim@mail.ru
 
Relative put/get data (big-endian order) into/from auto expandable byte array.
Data types: byte, byte[], short, int, long, float, double.
Float and double values are converted to IEEE 754 int/long.
 
The jar ./dist/bytearray-... file was generated with debugging info
using JDK1.8 for target JRE1.7
 
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 when resizing is disabled
 
int put(byte b);
int put(byte[] bytes);
int putShort(short s);
int putInt(int i);
int putFloat(float f);
int putLong(long l);
int putDouble(double d);
 
SET data methods. All methods returns this.
Can throw an ArrayIndexOutOfBoundsException when resizing is disabled
 
ByteArray set(byte b);
ByteArray set(byte[] bytes);
ByteArray setShort(short s);
ByteArray setInt(int i);
ByteArray setFloat(float f);
ByteArray setLong(long l);
ByteArray setDouble(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();