Class STTimedOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.io.output.ProxyOutputStream
com.io7m.brooklime.vanilla.internal.streamtime.STTimedOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public final class STTimedOutputStream extends org.apache.commons.io.output.ProxyOutputStream
A timed output stream. The stream accepts a function that will receive transfer statistics at a rate of one update per second.
  • Constructor Details

    • STTimedOutputStream

      public STTimedOutputStream(ScheduledExecutorService inExecutor, Consumer<STTransferStatistics> statsConsumer, OutputStream inStream)
      Create an output stream.
      Parameters:
      inExecutor - A statistics executor
      statsConsumer - A function that receives statistics updates
      inStream - The underlying output stream
    • STTimedOutputStream

      public STTimedOutputStream(ScheduledExecutorService inExecutor, OptionalLong expected, Consumer<STTransferStatistics> statsConsumer, OutputStream inStream)
      Create an output stream.
      Parameters:
      inExecutor - A statistics executor
      expected - The expected total number of octets that will be transferred
      statsConsumer - A function that receives statistics updates
      inStream - The underlying output stream
  • Method Details

    • write

      public void write(byte[] b, int off, int len) throws IOException
      Overrides:
      write in class org.apache.commons.io.output.ProxyOutputStream
      Throws:
      IOException
    • write

      public void write(byte[] b) throws IOException
      Overrides:
      write in class org.apache.commons.io.output.ProxyOutputStream
      Throws:
      IOException
    • write

      public void write(int b) throws IOException
      Overrides:
      write in class org.apache.commons.io.output.ProxyOutputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class org.apache.commons.io.output.ProxyOutputStream
      Throws:
      IOException