Package com.jalios.io

Class MonitoredInputStream

All Implemented Interfaces:
Closeable, AutoCloseable

public class MonitoredInputStream extends BufferedInputStream
A BufferedInputStream that count bytes read to display the status of the stream.
Author:
Jean-Philippe
  • Field Details

    • maxlength

      protected long maxlength
    • readlength

      protected long readlength
    • startingTime

      protected long startingTime
  • Constructor Details

    • MonitoredInputStream

      public MonitoredInputStream(InputStream stream, int size, long maxlength)
  • Method Details

    • read

      public int read() throws IOException
      Delegate Read to super class, count charactere read.
      Overrides:
      read in class BufferedInputStream
      Throws:
      IOException
      See Also:
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Delegate Read to super class, count charactere read.
      Overrides:
      read in class BufferedInputStream
      Throws:
      IOException
      See Also:
    • getStatus

      public long getStatus(boolean absolute, boolean done)
      Return the status of the stream. How many bytes have been read.
      Parameters:
      absolute - if return an absolute value or percentage
      done - if return the available byte or done bytes
      Returns:
      long the status of the stream
    • getSpentTime

      public long getSpentTime(boolean elapse)
      Return the time spent into this output stream
      Parameters:
      elapse - true return time spent, false return time to spent
      Returns:
      the duration
      Since:
      jcms-4.2
    • getMaxLength

      public long getMaxLength()
      Returns the maxLength of the inputStream
      Returns:
      the maxLength of the inputStream