Class LimitedOutputStream

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

public class LimitedOutputStream extends FilterOutputStream
Pass data to the underlying system until a given amount of bytes is reached.
  • Constructor Details

    • 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 Details

    • 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.