org.helidb.io
Class FixedSizeByteArrayOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.helidb.io.FixedSizeByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class FixedSizeByteArrayOutputStream
extends OutputStream

This is a variant of ByteArrayOutputStream that writes to a preallocated byte array. This may speed up operations somewhat.

Since:
1.0
Author:
Karl Gustafsson
In_jar:
helidb-core

Constructor Summary
FixedSizeByteArrayOutputStream(byte[] arr)
           
 
Method Summary
 void close()
           
 void flush()
           
 byte[] toByteArray()
          This returns this output stream's array.
 void write(byte[] barr)
           
 void write(byte[] barr, int offset, int length)
           
 void write(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedSizeByteArrayOutputStream

public FixedSizeByteArrayOutputStream(byte[] arr)
Method Detail

write

public void write(byte[] barr)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] barr,
                  int offset,
                  int length)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

close

public void close()
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream

toByteArray

public byte[] toByteArray()
This returns this output stream's array. The array returned is the actual array used by this object, so be careful not to modify it.

Returns:
This stream's byte array.