Class STTimedInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.commons.io.input.ProxyInputStream
com.io7m.brooklime.vanilla.internal.streamtime.STTimedInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

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

    • STTimedInputStream

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

      public STTimedInputStream(ScheduledExecutorService inExecutor, OptionalLong expected, Consumer<STTransferStatistics> statsConsumer, InputStream inStream)
      Create an input 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 input stream
  • Method Details

    • read

      public int read() throws IOException
      Overrides:
      read in class org.apache.commons.io.input.ProxyInputStream
      Throws:
      IOException
    • read

      public int read(byte[] bts, int off, int len) throws IOException
      Overrides:
      read in class org.apache.commons.io.input.ProxyInputStream
      Throws:
      IOException
    • read

      public int read(byte[] b) throws IOException
      Overrides:
      read in class org.apache.commons.io.input.ProxyInputStream
      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.input.ProxyInputStream
      Throws:
      IOException