org.xbill.DNS.utils
Class DataByteInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.ByteArrayInputStream
              |
              +--org.xbill.DNS.utils.DataByteInputStream

public class DataByteInputStream
extends ByteArrayInputStream

An extension of ByteArrayInputStream to support directly reading types used by DNS routines.

See Also:
DataByteOutputStream

Fields inherited from class java.io.ByteArrayInputStream
buf, count, mark, pos
 
Constructor Summary
DataByteInputStream(byte[] b)
          Creates a new DataByteInputStream
 
Method Summary
 int getPos()
          Get the current position in the stream
 int read(byte[] b)
          Read data from the stream.
 BigInteger readBigInteger(int len)
          Read a BigInteger from the stream, encoded as binary data.
 byte readByte()
          Read a byte from the stream
 int readInt()
          Read an int from the stream
 long readLong()
          Read a long from the stream
 short readShort()
          Read a short from the stream
 String readString()
          Read a String from the stream, represented as a length byte followed by data
 int readUnsignedByte()
          Read an unsigned byte from the stream
 int readUnsignedShort()
          Read an unsigned short from the stream
 void skipBytes(int n)
          Read and ignore bytes from the stream
 
Methods inherited from class java.io.ByteArrayInputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataByteInputStream

public DataByteInputStream(byte[] b)
Creates a new DataByteInputStream
Parameters:
b - The byte array to read from
Method Detail

read

public int read(byte[] b)
         throws IOException
Read data from the stream.
Overrides:
read in class InputStream
Parameters:
b - The array to read into
Returns:
The number of bytes read

readByte

public byte readByte()
              throws IOException
Read a byte from the stream
Returns:
The byte

readUnsignedByte

public int readUnsignedByte()
                     throws IOException
Read an unsigned byte from the stream
Returns:
The unsigned byte as an int

readShort

public short readShort()
                throws IOException
Read a short from the stream
Returns:
The short

readUnsignedShort

public int readUnsignedShort()
                      throws IOException
Read an unsigned short from the stream
Returns:
The unsigned short as an int

readInt

public int readInt()
            throws IOException
Read an int from the stream
Returns:
The int

readLong

public long readLong()
              throws IOException
Read a long from the stream
Returns:
The long

readString

public String readString()
                  throws IOException
Read a String from the stream, represented as a length byte followed by data
Returns:
The String

readBigInteger

public BigInteger readBigInteger(int len)
                          throws IOException
Read a BigInteger from the stream, encoded as binary data. A 0 byte is prepended so that the value is always positive.
Parameters:
len - The number of bytes to read
Returns:
The BigInteger

skipBytes

public void skipBytes(int n)
               throws IOException
Read and ignore bytes from the stream
Parameters:
n - The number of bytes to skip

getPos

public int getPos()
Get the current position in the stream
Returns:
The current position