com.sshtools.util
Class ByteArrayWriter

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.ByteArrayOutputStream
              |
              +--com.sshtools.util.ByteArrayWriter

public class ByteArrayWriter
extends java.io.ByteArrayOutputStream

Provides a reader type interface into the ByteArrayOutputStream

Version:
1.0
Author:
Lee David Painter ( lee@sshtools.com )

Field Summary
 
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
 
Constructor Summary
ByteArrayWriter()
          Constructor for the ByteArrayWriter object
 
Method Summary
 void writeBigInteger(java.math.BigInteger bi)
          Writes a BigInteger to the array.
 void writeBinaryString(byte[] data)
          Writes a binary string to the byte array.
 void writeInt(int i)
           Writes an integer into the byte array.
 void writeInt(long i)
           Writes an integer into the byte array.
static void writeIntToArray(byte[] array, int pos, int value)
          Writes an integer into an array, starting at the position specified
 void writeString(java.lang.String str)
          Writes a string to the byte array.
 
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

ByteArrayWriter

public ByteArrayWriter()
Constructor for the ByteArrayWriter object

Method Detail

writeInt

public void writeInt(long i)
              throws java.io.IOException

Writes an integer into the byte array.

NOTE: This will be replaced with the UnsignedInteger class

Parameters:
i - A long value to write (will be truncated if greater than max integer size)
Throws:
java.io.IOException - Thrown if the array cannot be written to

writeInt

public void writeInt(int i)
              throws java.io.IOException

Writes an integer into the byte array.

NOTE: This will be replaced with the UnsignedInteger class

Parameters:
i - The integer value
Throws:
java.io.IOException - Thrown if the array cannot be written to

writeString

public void writeString(java.lang.String str)
                 throws java.io.IOException
Writes a string to the byte array. The method first writes the length of the string as an integer and then the string data.

Parameters:
str - The string to write
Throws:
java.io.IOException - Thrown if the array cannot be written to

writeBinaryString

public void writeBinaryString(byte[] data)
                       throws java.io.IOException
Writes a binary string to the byte array. The method first writes the length of the data as an integer and then the data itself.

Parameters:
data - The data to write
Throws:
java.io.IOException - Thrown if the array cannot be written to

writeBigInteger

public void writeBigInteger(java.math.BigInteger bi)
                     throws java.io.IOException
Writes a BigInteger to the array. The method first writes the length of the encoded data and then the data itself.

Parameters:
bi - The BigInteger to write
Throws:
java.io.IOException - Thrown if the array cannot be written to

writeIntToArray

public static void writeIntToArray(byte[] array,
                                   int pos,
                                   int value)
                            throws java.io.IOException
Writes an integer into an array, starting at the position specified

Parameters:
array - The array to write to
pos - The starting position
value - The integer value
Throws:
java.io.IOException - Thrown if there is not at least 4 bytes of data to write to from pos to the end of the array


Copyright © 2002 Sshtools.com. All Rights Reserved.