org.apache.james.jdkim.canon
Class LimitedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by org.apache.james.jdkim.canon.LimitedOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class LimitedOutputStream
extends FilterOutputStream

Pass data to the underlying system until a given amount of bytes is reached.


Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
LimitedOutputStream(OutputStream out, int limit)
           
 
Method Summary
 int getComputedBytes()
           
 boolean isLimited()
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.FilterOutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LimitedOutputStream

public LimitedOutputStream(OutputStream out,
                           int limit)
Parameters:
out - an output stream that will receive the "trucated" stream.
limit - a positive integer of the number of bytes to be passed to the underlying stream
Method Detail

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException

getComputedBytes

public int getComputedBytes()
Returns:
the number of bytes passed to the underlying stream

isLimited

public boolean isLimited()
Returns:
true if the limit has been reached and no data is being passed to the underlying stream.


Copyright © 2008-2009 The Apache Software Foundation. All Rights Reserved.