Package com.jalios.io

Class MonitoredInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

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

      Fields 
      Modifier and Type Field Description
      protected long maxlength  
      protected long readlength  
      protected long startingTime  
      • Fields inherited from class java.io.BufferedInputStream

        buf, count, marklimit, markpos, pos
      • Fields inherited from class java.io.FilterInputStream

        in
    • Constructor Summary

      Constructors 
      Constructor Description
      MonitoredInputStream​(java.io.InputStream stream, int size, long maxlength)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getMaxLength()
      Returns the maxLength of the inputStream
      long getSpentTime​(boolean elapse)
      Return the time spent into this output stream
      long getStatus​(boolean absolute, boolean done)
      Return the status of the stream.
      int read()
      Delegate Read to super class, count charactere read.
      int read​(byte[] b, int off, int len)
      Delegate Read to super class, count charactere read.
      • Methods inherited from class java.io.BufferedInputStream

        available, close, mark, markSupported, reset, skip
      • Methods inherited from class java.io.FilterInputStream

        read
      • Methods inherited from class java.io.InputStream

        nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • maxlength

        protected long maxlength
      • readlength

        protected long readlength
      • startingTime

        protected long startingTime
    • Constructor Detail

      • MonitoredInputStream

        public MonitoredInputStream​(java.io.InputStream stream,
                                    int size,
                                    long maxlength)
    • Method Detail

      • read

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

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Delegate Read to super class, count charactere read.
        Overrides:
        read in class java.io.BufferedInputStream
        Throws:
        java.io.IOException
        See Also:
        InputStream.read(byte[], int, int)
      • 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