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, writeTo
flush, write
public ByteArrayWriter()
public ByteArrayWriter(int length)
length
- public byte[] array()
public void move(int numBytes)
numBytes
- public void writeBigInteger(BigInteger bi) throws IOException
bi
- IOException
public void writeBoolean(boolean b)
b
- IOException
public void writeBinaryString(byte[] data) throws IOException
data
- IOException
public void writeBinaryString(byte[] data, int offset, int len) throws IOException
data
- offset
- len
- IOException
public void writeMPINT(BigInteger b)
public void writeShort(short s)
public void writeInt(long i) throws IOException
i
- IOException
public void writeInt(int i) throws IOException
i
- IOException
public static byte[] encodeInt(int i)
i
- public static void encodeInt(byte[] buf, int off, int i)
public void writeUINT32(UnsignedInteger32 value) throws IOException
IOException
public void writeUINT64(UnsignedInteger64 value) throws IOException
IOException
public static byte[] stripLeadingZeros(byte[] data)
public void writeUINT64(long value) throws IOException
IOException
public void writeString(String str) throws IOException
str
- IOException
public void writeString(String str, String charset) throws IOException
str
- charset
- IOException
public void silentClose()
public void dispose()
Copyright © 2024. All rights reserved.