public class ByteArrayReader extends ByteArrayInputStream
Utiltiy class to read common parameter types from a byte array.
Modifier and Type | Field and Description |
---|---|
static boolean |
encode |
buf, count, mark, pos
Constructor and Description |
---|
ByteArrayReader(byte[] buffer) |
ByteArrayReader(byte[] buffer,
int start,
int len)
Construct a reader.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
array()
Provides access to the underlying array
|
void |
dispose() |
static String |
getCharsetEncoding()
Get the current encoding being used for Strings variables.
|
int |
getPosition()
Get the current position within the array.
|
BigInteger |
readBigInteger()
Read a BigInteger from the array.
|
byte[] |
readBinaryString()
Read a binary string from the array.
|
boolean |
readBoolean()
Write a boolean value to the array.
|
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len)
Read until the buffer supplied is full.
|
long |
readInt()
Read an integer (4 bytes) from the array.
|
static long |
readInt(byte[] data,
int start)
Read an integer (4 bytes) from the array.
|
BigInteger |
readMPINT()
Reads a standard SSH1 MPINT using the first 16 bits as the length prefix
|
BigInteger |
readMPINT32()
Reads an MPINT using the first 32 bits as the length prefix
|
short |
readShort() |
static short |
readShort(byte[] data,
int start) |
String |
readString()
Read a String from the array.
|
String |
readString(String charset)
Read a String from the array converting using the given character set.
|
UnsignedInteger32 |
readUINT32() |
UnsignedInteger64 |
readUINT64() |
static void |
setCharsetEncoding(String charset)
Allows the default encoding to be overriden for String variables processed
by the class.
|
void |
silentClose() |
available, close, mark, markSupported, read, read, reset, skip
read
public ByteArrayReader(byte[] buffer, int start, int len)
buffer
- start
- len
- public ByteArrayReader(byte[] buffer)
public byte[] array()
public static void setCharsetEncoding(String charset)
charset
- UnsupportedEncodingException
public static String getCharsetEncoding()
public void readFully(byte[] b, int off, int len) throws IOException
b
- off
- len
- IOException
public boolean readBoolean() throws IOException
b
- IOException
public void readFully(byte[] b) throws IOException
IOException
public BigInteger readBigInteger() throws IOException
IOException
public UnsignedInteger64 readUINT64() throws IOException
IOException
public UnsignedInteger32 readUINT32() throws IOException
IOException
public static long readInt(byte[] data, int start)
data
- start
- public static short readShort(byte[] data, int start)
public byte[] readBinaryString() throws IOException
IOException
public long readInt() throws IOException
IOException
public String readString() throws IOException
IOException
public String readString(String charset) throws IOException
charset
- IOException
public short readShort() throws IOException
IOException
public BigInteger readMPINT32() throws IOException
IOException
public BigInteger readMPINT() throws IOException
IOException
public int getPosition()
public void silentClose()
public void dispose()
Copyright © 2024. All rights reserved.