javar.util
Class ByteWriter

java.lang.Object
  |
  +--javar.util.ByteWriter

public final class ByteWriter
extends Object

This class will simple keep track of writing bytes and caching byte arrays between instances.

Author:
Ben Litchfield (ben@csh.rit.edu)

Constructor Summary
ByteWriter()
          This will attempt to pull a byte array from the cache or create one if the cache is empty.
 
Method Summary
 void append(byte b)
          This will append a single byte to the array.
 void append(byte[] b)
          This will append a single byte to the array.
 byte[] close()
          This will create a new buffer of the correct size and return the old buffer to the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteWriter

public ByteWriter()
This will attempt to pull a byte array from the cache or create one if the cache is empty.

Method Detail

append

public final void append(byte b)
This will append a single byte to the array.

Parameters:
b - The byte to append

append

public final void append(byte[] b)
This will append a single byte to the array.

Parameters:
b - The byte[] to append

close

public final byte[] close()
This will create a new buffer of the correct size and return the old buffer to the cache.

Returns:
a buffer will all of the bytes that were written.