rabbit.io
Class MaxSizeOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byrabbit.io.MaxSizeOutputStream

public class MaxSizeOutputStream
extends java.io.OutputStream

A class that doesnt create outputstreams of more than a specified amount of data, the rest is simply swallowed


Constructor Summary
MaxSizeOutputStream(java.io.OutputStream os, long l)
          Creates a new MaxSizeOutputStream with a given limit and connects it to a given stream.
 
Method Summary
 void close()
          Close this stream.
 void flush()
          Write any pending data.
static void main(java.lang.String[] args)
          Simple self test
 void write(byte[] b)
          Write a byte array to this stream.
 void write(byte[] b, int off, int len)
          Write a byte array to this stream.
 void write(int b)
          Write a byte to this stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MaxSizeOutputStream

public MaxSizeOutputStream(java.io.OutputStream os,
                           long l)
Creates a new MaxSizeOutputStream with a given limit and connects it to a given stream.

Method Detail

write

public void write(int b)
           throws java.io.IOException
Write a byte to this stream.

Parameters:
b - the byte to write.
Throws:
java.io.IOException - if the underlying stream does.

write

public void write(byte[] b)
           throws java.io.IOException
Write a byte array to this stream.

Parameters:
b - the byte array to write.
Throws:
java.io.IOException - if the underlying stream does.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Write a byte array to this stream.

Parameters:
b - the byte to write.
off - the starting offset.
len - the number of bytes to write.
Throws:
java.io.IOException - if the underlying stream does.

flush

public void flush()
           throws java.io.IOException
Write any pending data.

Throws:
java.io.IOException - if the underlying stream does.

close

public void close()
           throws java.io.IOException
Close this stream.

Throws:
java.io.IOException - if the underlying stream does.

main

public static void main(java.lang.String[] args)
Simple self test