|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.InputStream | +--java.io.ByteArrayInputStream | +--com.sshtools.util.ByteArrayReader
Provides a reader type interface into the ByteArrayInputStream.
Field Summary |
Fields inherited from class java.io.ByteArrayInputStream |
buf, count, mark, pos |
Constructor Summary | |
ByteArrayReader(byte[] data)
Constructor for the ByteArrayReader object |
Method Summary | |
static int |
previewInt(byte[] data,
int start)
Previews an integer in the byte array provided. |
java.math.BigInteger |
readBigInteger()
Returns a BigInteger from the byte array. |
byte[] |
readBinaryString()
Returns a binary string from the byte array. |
long |
readInt()
Reads an integer from the byte array. |
java.lang.String |
readString()
Reads a string from the byte array, the format of the string will be 4 bytes representing an int value for the lengh of the string and then len bytes of data. |
Methods inherited from class java.io.ByteArrayInputStream |
available, close, mark, markSupported, read, read, reset, skip |
Methods inherited from class java.io.InputStream |
read |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ByteArrayReader(byte[] data)
data
- The byte array to be read.Method Detail |
public long readInt() throws java.io.IOException
Reads an integer from the byte array.
NOTE: This currently returns a long but only extracts 4 bytes. The reason behind this is that this class has been designed for SSH byte arrays; SSH uses unsigned integers but in java we do not have an unsigned integer type. To safely return the non negative value we must extract the byte information into a long to preserve the unsigned value. THIS WILL BE UPDATED SOON WITH THE UnsignedInteger class.
java.io.IOException
- Description of the Exceptionpublic static int previewInt(byte[] data, int start)
data
- The byte array to previewstart
- The start position in the array
public java.lang.String readString() throws java.io.IOException
java.io.IOException
- Thrown of the data cannot be readpublic byte[] readBinaryString() throws java.io.IOException
java.io.IOException
- Thrown if the data cannot be readpublic java.math.BigInteger readBigInteger() throws java.io.IOException
java.io.IOException
- Thrown if the data cannot be read
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |