org.intermine.util
Class SensibleByteArrayOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.ByteArrayOutputStream
          extended by org.intermine.util.SensibleByteArrayOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
PostgresByteArrayOutputStream

public class SensibleByteArrayOutputStream
extends java.io.ByteArrayOutputStream

A subclass of ByteArrayOutputStream that behaves a little more sensibly when handling large writes followed by small writes.


Field Summary
 
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
 
Constructor Summary
SensibleByteArrayOutputStream()
           
SensibleByteArrayOutputStream(int size)
           
 
Method Summary
 void assureSize(int newSize)
          Resizes the buffer to ensure it is as large as newSize.
 void write(byte[] b, int off, int len)
          
 void write(int b)
          
 
Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, 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

SensibleByteArrayOutputStream

public SensibleByteArrayOutputStream()
See Also:
ByteArrayOutputStream

SensibleByteArrayOutputStream

public SensibleByteArrayOutputStream(int size)
Parameters:
size - the initial size of the byte array
See Also:
ByteArrayOutputStream
Method Detail

write

public void write(int b)

Overrides:
write in class java.io.ByteArrayOutputStream

write

public void write(byte[] b,
                  int off,
                  int len)

Overrides:
write in class java.io.ByteArrayOutputStream

assureSize

public void assureSize(int newSize)
Resizes the buffer to ensure it is as large as newSize.

Parameters:
newSize - the new minimum size of the buffer