Class MonitoredInputStream

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

    public class MonitoredInputStream
    extends java.io.FilterInputStream
    An input stream that can be monitored using a ProgressListener. This is similar to a ProgressMonitorInputStream, except that it is more flexible in how the progress updates are used.
    Since:
    3.0
    Author:
    Chris Jennings
    • Field Summary

      • Fields inherited from class java.io.FilterInputStream

        in
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int read()
      Overrides FilterInputStream.read to update progress after the read.
      int read​(byte[] b)
      Overrides FilterInputStream.read to update progress after the read.
      int read​(byte[] b, int off, int len)
      Overrides FilterInputStream.read to update progress after the read.
      void reset()
      Overrides FilterInputStream.reset to reset progress listener as well as the stream.
      long skip​(long n)
      Overrides FilterInputStream.skip to update progress after the skip.
      • Methods inherited from class java.io.FilterInputStream

        available, close, mark, markSupported
      • 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
    • Constructor Detail

      • MonitoredInputStream

        public MonitoredInputStream​(ProgressListener li,
                                    java.io.InputStream in)
                             throws java.io.IOException
        Creates a new monitored input stream. The size of the incoming input stream will be estimated automatically.
        Parameters:
        li - the listener to update
        in - the input stream to monitor
        Throws:
        java.io.IOException - if an I/O error occurs
      • MonitoredInputStream

        public MonitoredInputStream​(ProgressListener li,
                                    long size,
                                    java.io.InputStream in)
                             throws java.io.IOException
        Creates a new monitored input stream.
        Parameters:
        li - the listener to update
        size - the number of bytes in the input stream
        in - the input stream to monitor
        Throws:
        java.io.IOException - if an I/O error occurs
      • MonitoredInputStream

        public MonitoredInputStream​(ProgressListener li,
                                    java.io.File in)
                             throws java.io.IOException
        Creates a new monitored input stream that reads from a file.
        Parameters:
        li - the listener to update
        in - the file to monitor
        Throws:
        java.io.IOException - if an I/O error occurs
    • Method Detail

      • read

        public int read()
                 throws java.io.IOException
        Overrides FilterInputStream.read to update progress after the read.
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b)
                 throws java.io.IOException
        Overrides FilterInputStream.read to update progress after the read.
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Overrides FilterInputStream.read to update progress after the read.
        Overrides:
        read in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • skip

        public long skip​(long n)
                  throws java.io.IOException
        Overrides FilterInputStream.skip to update progress after the skip.
        Overrides:
        skip in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • reset

        public void reset()
                   throws java.io.IOException
        Overrides FilterInputStream.reset to reset progress listener as well as the stream.
        Overrides:
        reset in class java.io.FilterInputStream
        Throws:
        java.io.IOException