public class ByteArrayWriter extends ByteArrayOutputStream
Utility class to write common parameter types to a byte array.
buf, count| Constructor and Description |
|---|
ByteArrayWriter()
Contruct an empty writer.
|
ByteArrayWriter(int length)
Construct a writer with an array size of the length supplied.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
array()
Get the underlying byte array
|
void |
dispose() |
static void |
encodeInt(byte[] buf,
int off,
int i) |
static byte[] |
encodeInt(int i)
Encode an integer into a 4 byte array.
|
void |
move(int numBytes)
Move the position of the next byte to be written.
|
void |
silentClose() |
static byte[] |
stripLeadingZeros(byte[] data) |
void |
writeBigInteger(BigInteger bi)
Write a BigInteger to the array.
|
void |
writeBinaryString(byte[] data)
Write a binary string to the array.
|
void |
writeBinaryString(byte[] data,
int offset,
int len)
Write a binary string to the array.
|
void |
writeBoolean(boolean b)
Write a boolean value to the array.
|
void |
writeInt(int i)
Write an integer to the array.
|
void |
writeInt(long i)
Write an integer to the array
|
void |
writeMPINT(BigInteger b) |
void |
writeShort(short s) |
void |
writeString(String str)
Write a string to the byte array.
|
void |
writeString(String str,
String charset)
Write a String to the byte array converting the bytes using the
given character set.
|
void |
writeUINT32(UnsignedInteger32 value) |
void |
writeUINT64(long value) |
void |
writeUINT64(UnsignedInteger64 value) |
close, reset, size, toByteArray, toString, toString, toString, write, write, writeToflush, writepublic ByteArrayWriter()
public ByteArrayWriter(int length)
length - public byte[] array()
public void move(int numBytes)
numBytes - public void writeBigInteger(BigInteger bi) throws IOException
bi - IOExceptionpublic void writeBoolean(boolean b)
b - IOExceptionpublic void writeBinaryString(byte[] data)
throws IOException
data - IOExceptionpublic void writeBinaryString(byte[] data,
int offset,
int len)
throws IOException
data - offset - len - IOExceptionpublic void writeMPINT(BigInteger b)
public void writeShort(short s)
public void writeInt(long i)
throws IOException
i - IOExceptionpublic void writeInt(int i)
throws IOException
i - IOExceptionpublic static byte[] encodeInt(int i)
i - public static void encodeInt(byte[] buf,
int off,
int i)
public void writeUINT32(UnsignedInteger32 value) throws IOException
IOExceptionpublic void writeUINT64(UnsignedInteger64 value) throws IOException
IOExceptionpublic static byte[] stripLeadingZeros(byte[] data)
public void writeUINT64(long value)
throws IOException
IOExceptionpublic void writeString(String str) throws IOException
str - IOExceptionpublic void writeString(String str, String charset) throws IOException
str - charset - IOExceptionpublic void silentClose()
public void dispose()
Copyright © 2025. All rights reserved.