org.apache.hcatalog.templeton
Class MaxByteArrayOutputStream

Object
  extended by OutputStream
      extended by ByteArrayOutputStream
          extended by MaxByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class MaxByteArrayOutputStream
extends ByteArrayOutputStream

An output stream that will only accept the first N bytes of data.


Field Summary
 
Fields inherited from class ByteArrayOutputStream
buf, count
 
Constructor Summary
MaxByteArrayOutputStream(int maxBytes)
          Create.
 
Method Summary
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this byte array output stream.
 void write(int b)
          Writes the specified byte to this byte array output stream.
 
Methods inherited from class ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, writeTo
 
Methods inherited from class OutputStream
flush, write
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MaxByteArrayOutputStream

public MaxByteArrayOutputStream(int maxBytes)
Create.

Method Detail

write

public void write(int b)
Writes the specified byte to this byte array output stream. Any bytes after the first maxBytes will be ignored.

Overrides:
write in class ByteArrayOutputStream
Parameters:
b - the byte to be written.

write

public void write(byte[] b,
                  int off,
                  int len)
Writes len bytes from the specified byte array starting at offset off to this byte array output stream. Any bytes after the first maxBytes will be ignored.

Overrides:
write in class ByteArrayOutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.