org.xbill.DNS.utils
Class DataByteOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.ByteArrayOutputStream
              |
              +--org.xbill.DNS.utils.DataByteOutputStream

public class DataByteOutputStream
extends ByteArrayOutputStream

An extension of ByteArrayOutputStream to support directly writing types used by DNS routines.

See Also:
DataByteInputStream

Fields inherited from class java.io.ByteArrayOutputStream
buf, count
 
Constructor Summary
DataByteOutputStream()
          Create a new DataByteOutputStream with the default initial size
DataByteOutputStream(int size)
          Create a new DataByteOutputStream with a specified initial size
 
Method Summary
 int getPos()
          Get the current position in the stream
 void writeBigInteger(BigInteger i)
          Writes a BigInteger to the stream, encoded as binary data.
 void writeByte(int i)
          Writes a byte to the stream
 void writeInt(int i)
          Writes an int to the stream
 void writeLong(long l)
          Writes a long to the stream
 void writeShort(int i)
          Writes a short to the stream
 void writeShortAt(int i, int pos)
          Writes a short to the stream at a specific location
 void writeString(String s)
          Writes a String to the stream, encoded as a length byte followed by data
 void writeStringCanonical(String s)
          Writes a canonical String to the stream, encoded as a length byte followed by data
 
Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, write, write, writeTo
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataByteOutputStream

public DataByteOutputStream(int size)
Create a new DataByteOutputStream with a specified initial size
Parameters:
size - The initial size

DataByteOutputStream

public DataByteOutputStream()
Create a new DataByteOutputStream with the default initial size
Parameters:
size - The initial size
Method Detail

writeByte

public void writeByte(int i)
Writes a byte to the stream
Parameters:
i - The byte to be written

writeShort

public void writeShort(int i)
Writes a short to the stream
Parameters:
i - The short to be written

writeInt

public void writeInt(int i)
Writes an int to the stream
Parameters:
i - The int to be written

writeLong

public void writeLong(long l)
Writes a long to the stream
Parameters:
l - The long to be written

writeString

public void writeString(String s)
Writes a String to the stream, encoded as a length byte followed by data
Parameters:
s - The String to be written

writeStringCanonical

public void writeStringCanonical(String s)
Writes a canonical String to the stream, encoded as a length byte followed by data
Parameters:
s - The String to be written

writeBigInteger

public void writeBigInteger(BigInteger i)
Writes a BigInteger to the stream, encoded as binary data. If present, the leading 0 byte is removed.
Parameters:
i - The BigInteger to be written

writeShortAt

public void writeShortAt(int i,
                         int pos)
                  throws IllegalArgumentException
Writes a short to the stream at a specific location
Parameters:
i - The short to be written
pos - The position at which the write occurs

getPos

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